RE: How does my default get undefined?

2003-02-13 Thread Alistair . McGlinchy
Richard,

 %hash_default = %hash;
This does not copy the arrays or hashes referenced in the values of the
hash. Remember a hash is an associative list of scalars. 

%hash = ($key1, $value1);
So if you say:
%hash_default = %hash;
%hash_default is now equal ($key1, $value1);

If $value1 happens to be a reference to an object then both hashes' values
now point to the *same* object. For example:

$hash{fred}{barney}=1; # %hash is (fred,Ref to anon hash
(barney,1));
%hash_default = %hash; # copy %hash
$hash_default{fred}{barney}++; # increment the anonymous hash's value
print $hash{fred}{barney}  # prints 2;

For your particular example with a data structure two levels deep you'll
need to loop over all of the keys of the first level;

for my $key, (keys %hash) {
%{$hash_default2{$key}} = %{$hash{$key}}
}

If you have a more complicated data structure. You'll need a more
complicated loop. 
See the FAQ on copying data structures:

D:\perldoc -q copy
Found in D:\perl\lib\pod\perlfaq4.pod
  How do I print out or copy a recursive data structure?
snip

See also:  perlref.html and perlreftut.html

HTH

Alistair


---


Registered Office:
Marks  Spencer p.l.c
Michael House, Baker Street,
London, W1U 8EP
Registered No. 214436 in England and Wales.

Telephone (020) 7935 4422 
Facsimile (020) 7487 2670

www.marksandspencer.com

Please note that electronic mail may be monitored.

This e-mail is confidential. If you received it by mistake, please let us know and 
then delete it from your system; you should not copy, disclose, or distribute its 
contents to anyone nor act in reliance on this e-mail, as this is prohibited and may 
be unlawful.

The registered office of Marks and Spencer Financial Services PLC, Marks and Spencer 
Unit Trust Management Limited, Marks and Spencer Life Assurance Limited and Marks and 
Spencer Savings and Investments Limited is Kings Meadow, Chester, CH99 9FB.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



XP explorer and AddConnection

2003-02-13 Thread Grakowsky, Richard \(ETS: Communications and Network Services\)








Hello All,



I'm working on what was supposed to be a simple little
script to allow users on WinXP systems to remap drives to some DFS shares
without having to logoff/on to the systems (classroom environment). When
I run the app, I can get to the drives contents from the CMD prompt, but
Windows Explorer does not display all of the drives. I'm trying it on 2
drives and it will show one or the other, sometimes neither, but never
both. Closing and re-opening explorer does not make a difference and I
cannot get to the drives by doing Start - Run - driveletter.
If I kill and restart the explorer service (via task manager or on the command
line) the drives will appear when explorer restarts. For a variety of
reasons, I dont want to restart explorer in support of this little
script. Heres some of the code (the share names have been changed
to protect the innocent)...



my(%drvarray) = ( X:,mydomain.com\\dfs\\pathto\\firstshare,


Y:,mydomain.com\\dfs\\pathto\\secondshare


);

 #-- Do the work

 eval {

 $ncref = {};

 $ncref-{'Scope'} =
RESOURCE_GLOBALNET;

 $ncref-{'Type'} = RESOURCETYPE_DISK;

 $ncref-{'DisplayType'} =
RESOURCEDISPLAYTYPE_SHARE;

 $ncref-{'Usage'} =
RESOURCEUSAGE_CONNECTABLE;

 #-- Disconnect the drives first

 #-- Cannot connect dfs drives under
different usernames

 foreach $letter (keys %drvarray) {
Win32::NetResource::CancelConnection($letter,0,1); }

 #-- Now connect them again using the
credentials

 foreach $letter (keys %drvarray) {

 $ncref-{'LocalName'} =
$letter;

 $ncref-{'RemoteName'} = $drvarray{$letter};


if(!Win32::NetResource::AddConnection($ncref,$password,$username,0)) {

 Win32::NetResource::GetError($err);

 die
Win32::FormatMessage($err);

 }

 }

 };



I'm using ActivePerl v5.6.1 Build 631/633 and the subroutine
is being called from a TK form the simply prompts the user for their username
and password. Anyone seen this before? Is there anyway to force
Windows Explorer to re-query for drives like it does when its
restarted? I was going to try and use Win32::FileOp but it does not
appear to be bundled with this distribution of Perl and with this script
potentially going out on hundreds of clients, I dont want to require the
installation of a specific module if at all possible.



Thanks in advance.

Thanks,
Rick

Richard Grakowsky
Systems Specialist, Monroe Community College
[EMAIL PROTECTED]
585.292.3236 
Progress occurs when we are no longer
willing
to accept the consequences of
inaction.










RE: How does my default get undefined?

2003-02-13 Thread Beckett Richard-qswi266
 Richard,
 
  %hash_default = %hash;
 This does not copy the arrays or hashes referenced in the 
 values of the
 hash. Remember a hash is an associative list of scalars. 

Oh bum! :-)

That explains why very occasionally, it would seem to work, but I could
never reproduce the circumstances that caused it.

At least I know where to start reading now!

Thanks.

R. 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Install SSL support for Windows?

2003-02-13 Thread Randy Kobes
On Thu, 13 Feb 2003, Frazier, Joe Jr wrote:

 What da heck do I have to do to get SSL to work with LWP?  I
 installed Crypt::SSLeay and Net_SSLeay.pm from PPM.  I then
 found a binary for openssl9.6g and copyed into my path ( I was
 getting an error stating that it could not find ssleay32.dll,
 so I renamed libssl32.dll to ssleay32.dll per the install
 directions.)
 
 Now, when I run the simple perl -MLWP::Simple -e
 getprint('https://my.peopleclick.com'), I get a windows
 message box stating that The ordinal 3212 could not be located
 in the dynamic link library libeay32.dll and LWP STILL says
 501 Protocol scheme 'https' is not supported
 URL:https://my.peopleclick.com.

If the Crypt::SSLeay ppm package you got was from our
repository (http://theoryx5.uwinnipeg.ca/ppms/ or
http://theoryx5.uwinnipeg.ca/ppmpackages/), the needed
libeay32.dll and ssleay32.dll libs are available under
ftp://theoryx5.uwinnipeg.ca/pub/other/.

-- 
best regards,
randy kobes

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Install SSL support for Windows?

2003-02-13 Thread Frazier, Joe Jr
 -Original Message-
 From: Randy Kobes [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, February 13, 2003 9:16 AM
 To: Frazier, Joe Jr
 Cc: [EMAIL PROTECTED]
 Subject: Re: Install SSL support for Windows?
 
 
 On Thu, 13 Feb 2003, Frazier, Joe Jr wrote:
 
  What da heck do I have to do to get SSL to work with LWP?  I
  installed Crypt::SSLeay and Net_SSLeay.pm from PPM.  I then
  found a binary for openssl9.6g and copyed into my path ( I was
  getting an error stating that it could not find ssleay32.dll,
  so I renamed libssl32.dll to ssleay32.dll per the install
  directions.)
  
  Now, when I run the simple perl -MLWP::Simple -e
  getprint('https://my.peopleclick.com'), I get a windows
  message box stating that The ordinal 3212 could not be located
  in the dynamic link library libeay32.dll and LWP STILL says
  501 Protocol scheme 'https' is not supported
  URL:https://my.peopleclick.com.
 
 If the Crypt::SSLeay ppm package you got was from our
 repository (http://theoryx5.uwinnipeg.ca/ppms/ or
 http://theoryx5.uwinnipeg.ca/ppmpackages/), the needed
 libeay32.dll and ssleay32.dll libs are available under
 ftp://theoryx5.uwinnipeg.ca/pub/other/.
 
 -- 
 best regards,
 randy kobes
 

Thanks Randy, that worked.  I guess my guess my biggest gripe is Windows has enough of 
its own quirks, why can't windows users easily find the binaries they need to use free 
software modules.  (ie, if a module requires a dll, either include it or tell people 
how to get it.).

Anyway, thanks again Randy.  This is the second (or third) time you have directly 
helped me and I really appreciate everything you are doing on the site for hosting 
ppms(and up to date at that) that Activestate cannot or will not.



Joe
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Deciphering DBI trace fro DBD-XBase

2003-02-13 Thread Adam Frielink
I posted this yesterday on the Win32-database list and got no response.  Can
anyone help with this problem?



I am trying to debug this script of mine, but I cannot seen to understand
why  I get the following error...

Tk::Error: Can't locate object method new via package XBase at
C:/Perl/site/lib/DBD/XBase.pm line 327.

This application worked under 628.  I recently wiped my AS perl build 628
and installed build 804.  I then used the VPM and installed these two
modules, so I believe I have the current versions as there are no updates
available.  Anyone have any thoughts?  Thanks for any assistance.

__BEGINSNIP__
   DBI-trace(1);
my $OUTdbh =  DBI-connect('dbi:XBase:' . cwd()) or die Cannot Connect to
XBase DB: $DBI::errstr\n;
print (BuildTemporaryDatabase) Connect XBase\n;

#unlink cwd() . $OUTtable . '.dbf' or die Cannot Drop Table $OUTtable:
$!\n if (-f cwd() . $OUTtable . '.dbf') ;   #Drop the XBase table if it
exists
my $DROPsth = $OUTdbh-prepare(DROP TABLE $OUTtable) or warn Table
doesn't Exist: $DBI::errstr\n;
$DROPsth-execute or die Table Doesn't Exist and cannot drop:
$DBI::errstr\n;
   DBI-trace(0);

__ENDSNIP__


__BEGINTRACE__
DBI 1.30-ithread dispatch trace level set to 3
Note: perl is running without the recommended perl -w option
- DBI-connect(dbi:XBase:C:/Documents and
Settings/Adam/Desktop/tycoproj/RemoteSI, , )
- DBI-install_driver(XBase) for MSWin32 perl=5.008 pid=168 ruid=0
euid=0
   install_driver: DBD::XBase version 0.231 loaded from
C:/Perl/site/lib/DBD/XBase.pm
New DBI::dr (for DBD::XBase::dr, parent=, id=)
dbih_setup_handle(DBI::dr=HASH(0x1d2c844)=DBI::dr=HASH(0x1d2cf04),
DBD::XBase::dr, 0, Null!)
dbih_make_com(Null!, DBD::XBase::dr, 172) thr#2243ac
- install_driver= DBI::dr=HASH(0x1d2c844)
- default_user in DBD::_::dr for DBD::XBase::dr
(DBI::dr=HASH(0x1d2c844)~0x1d2cf04 undef undef HASH(0x2c720dc)) thr#2243ac
- default_user= ( undef undef ) [2 items] at DBI.pm line 500 via
C:/Perl/site/lib/Tk.pm line 228
- connect (StartReport) Report Value: Shipto
for DBD::XBase::dr (DBI::dr=HASH(0x1d2c844)~0x1d2cf04 'C:/Documents and
Settings/Adam/Desktop/tycoproj/RemoteSI' undef  HASH(0x2c720dc))
thr#2243ac
New DBI::db (for DBD::XBase::db, parent=DBI::dr=HASH(0x1d2cf04), id=)
dbih_setup_handle(DBI::db=HASH(0x1d2cee0)=DBI::db=HASH(0x1d2cdf0),
DBD::XBase::db, 1d2cba4, Null!)
dbih_make_com(DBI::dr=HASH(0x1d2cf04), DBD::XBase::db, 172) thr#2243ac
- connect= DBI::db=HASH(0x1d2cee0) at DBI.pm line 503 via
C:/Perl/site/lib/Tk.pm line 228
- STORE for DBD::XBase::db (DBI::db=HASH(0x1d2cdf0)~INNER 'PrintError'
1) thr#2243ac
STORE DBI::db=HASH(0x1d2cdf0) 'PrintError' = 1
- STORE= 1 at DBI.pm line 545 via C:/Perl/site/lib/Tk.pm line 228
- STORE for DBD::XBase::db (DBI::db=HASH(0x1d2cdf0)~INNER 'AutoCommit'
1) thr#2243ac
- STORE= 1 at DBI.pm line 545 via C:/Perl/site/lib/Tk.pm line 228
- connect= DBI::db=HASH(0x1d2cee0)
- prepare for DBD::XBase::db (DBI::db=HASH(0x1d2cee0)~0x1d2cdf0 'DROP
TABLE CBSAL') thr#2243a(BuildTemporaryDatabase) Report Value: Shipto
(BuildTemporaryDatabase) Connect CSV
(BuildTemporaryDatabase) Connect XBase
c
New DBI::st (for DBD::XBase::st, parent=DBI::db=HASH(0x1d2cdf0), id=)
dbih_setup_handle(DBI::st=HASH(0x1d2cec8)=DBI::st=HASH(0x1d2ce2c),
DBD::XBase::st, 1d2ce5c, Null!)
dbih_make_com(DBI::db=HASH(0x1d2cdf0), DBD::XBase::st, 172) thr#2243ac
- prepare= DBI::st=HASH(0x1d2cec8) at currentmonthbooked.pl line 408
via C:/Perl/site/lib/Tk.pm line 228
- execute for DBD::XBase::st (DBI::st=HASH(0x1d2cec8)~0x1d2ce2c)
thr#2243ac
 DESTROY ignored for outer handle DBI::st=HASH(0x1d2cec8) (inner
DBI::st=HASH(0x1d2ce2c))
- DESTROY for DBD::XBase::st (DBI::st=HASH(0x1d2ce2c)~INNER) thr#2243ac
- DESTROY= undef at perl5db.pl line 1503 via C:/Perl/site/lib/Tk.pm
line 340
 DESTROY ignored for outer handle DBI::db=HASH(0x1d2cee0) (inner
DBI::db=HASH(0x1d2cdf0))
- DESTROY for DBD::XBase::db (DBI::db=HASH(0x1d2cdf0)~INNER) thr#2243ac
- DESTROY= undef at perl5db.pl line 1503 via C:/Perl/site/lib/Tk.pm
line 340
 DESTROY ignored for outer handle DBI::db=HASH(0x1d2c7c0) (inner
DBI::db=HASH(0x1c89a14))
- DESTROY in DBD::File::db for DBD::CSV::db
(DBI::db=HASH(0x1c89a14)~INNER) thr#2243ac
- DESTROY= undef at perl5db.pl line 1503 via C:/Perl/site/lib/Tk.pm
line 340
Tk::Error: Can't locate object method new via package XBase at
C:/Perl/site/lib/DBD/XBase.pm line 327.
 [\main::__ANON__[C:\Documents and
Settings\Adam\Desktop\tycoproj\RemoteSI\currentmonthbooked.pl:157]]
 Tk callback for .button1
 Tk::__ANON__[C:/Perl/site/lib/Tk.pm:228] at C:/Perl/site/lib/Tk.pm line 228
 Tk::Button::butUp at C:/Perl/site/lib/Tk/Button.pm line 113
 (command bound to event)
-- DBI::END
- disconnect_all in DBD::File::dr for DBD::CSV::dr
(DBI::dr=HASH(0x1e121ac)~0x1d2c0dc) thr#2243ac
- disconnect_all= undef at DBI.pm line 

Re: Deciphering DBI trace fro DBD-XBase

2003-02-13 Thread michael higgins
Adam Frielink wrote:

I posted this yesterday on the Win32-database list and got no response.  Can
anyone help with this problem?



I am trying to debug this script of mine, but I cannot seen to understand
why  I get the following error...

Tk::Error: Can't locate object method new via package XBase at
C:/Perl/site/lib/DBD/XBase.pm line 327.

This application worked under 628.  I recently wiped my AS perl build 628
and installed build 804.  I then used the VPM and installed these two
modules, so I believe I have the current versions as there are no updates
available.  Anyone have any thoughts?  Thanks for any assistance.


[snipped]

Hello Adam --

Funny you should send this today.

Unless I'm completely fogged, this may be the clue trail to follow:

The other day I thought I'd be helpful and reply to a post about 
Xbase.pm. I looked at the post, looked at my install, 'realized' I was a 
few cliks out of date and 'upgraded'... to Xbase.PM 1.07. From  
like... 0.92..??

Looking at my DBD::XBase module (note the ... um... 'b' vs. 'B'?)... it 
calls for this module:

 use XBase;

See the capital bee?

My scripts now die with the same error your trace found. Ouch.

PPM Search xbase yeilds:

Packages available from 
http://ppm.ActiveState.com/cgibin/PPM/ppmserver.pl?urn:/
PPMServer:
DBD-XBase [0.231] Reads and writes XBase (dbf) files, includes DBI support
Xbase [1.07 ] Perl Module to Read Xbase DBF Files and Foxpro IDX indexes


So, I have to try to undo my 'upgrade' (oh, how I wish I weren't on a 
windoze box this week! AARgghhh!) -- and let you know what I find for 
the good, old XBase (with a capital Bee).


-- mike higgins


 ^ ^
-|-
 (.)__ the world is a big box of paints.
__ __  and others, the canvas we're dealt.
 | | -  XTC
_/ \_

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Deciphering DBI trace fro DBD-XBase

2003-02-13 Thread michael higgins
Adam Frielink wrote:

I posted this yesterday on the Win32-database list and got no response.  Can
anyone help with this problem?




[snip]

And to followup, thankfully, I have a separate install on my box at the 
office.

Replacing 'Xbase.pm' ver  1.07  with 'XBase.pm ver $VERSION = '0.210'; 
(which came, I BELIEVE with my AS 633 build...).

Of course, windows won't let the two co-exist, so, the new module, well, 
I had to rename it. Dunno the implications of that yet.

My first indication of trouble was the scripts I had made to use the 
XBase module allowed me to access the cdx with this type of string:
$table-prepare_select_with_index(['./dpwcopy/dp.cdx','USER0','-type=char'],... 


The newer version (was still hacking around with it) wasn't documenting 
this ability ...

Anyway, HTH.


--Mike Higgins


 ^ ^
-|-
 (.)__ the world is a big box of paints.
__ __  and others, the canvas we're dealt.
 | | -  XTC
_/ \_

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Deciphering DBI trace fro DBD-XBase

2003-02-13 Thread michael higgins
michael higgins wrote:

Adam Frielink wrote:


I posted this yesterday on the Win32-database list and got no 
response.  Can
anyone help with this problem?



[snip]

And to followup, thankfully, I have a separate install on my box at the 
office.

Replacing 'Xbase.pm' ver  1.07  with 'XBase.pm ver $VERSION = '0.210'; 
(which came, I BELIEVE with my AS 633 build...).

Of course, windows won't let the two co-exist, so, the new module, well, 
I had to rename it. Dunno the implications of that yet.

My first indication of trouble was the scripts I had made to use the 
XBase module allowed me to access the cdx with this type of string:
$table-prepare_select_with_index(['./dpwcopy/dp.cdx','USER0','-type=char'],... 


The newer version (was still hacking around with it) wasn't documenting 
this ability ...

Anyway, HTH.
[snip]

And following up to my followup, I note that the newest DBD-XBase 
(DBD-XBase-0.231) provides the 'correct' XBase.pm. in a version '0.220.

So, it'd appear that an upgrade to that package, without the other, will 
overwrite the non-compatible-to-DBD::XBase 'Xbase.pm' module.

Enough.

-- Mike Higgins


 ^ ^
-|-
 (.)__ the world is a big box of paints.
__ __  and others, the canvas we're dealt.
 | | -  XTC
_/ \_

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


question about grep

2003-02-13 Thread Hawley, Eric
I got a question concerning grep.  I would like to use it to pull out all
full lines of text, that starts with the word Status, from a list of
files.  I am not really too experienced with using Metacharacters and
Metasymbols and do not know how to go about doing this with grep.  Can
someone help me out with this?

Thanks in advanced
Eric
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: question about grep

2003-02-13 Thread Peter Guzis
@matches = grep /^Status/, @data;

If this doesn't do it you might consider posting some sample data.

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-Original Message-
From: Hawley, Eric [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 10:23 AM
To: Perl-Win32 (E-mail)
Subject: question about grep


I got a question concerning grep.  I would like to use it to pull out all
full lines of text, that starts with the word Status, from a list of
files.  I am not really too experienced with using Metacharacters and
Metasymbols and do not know how to go about doing this with grep.  Can
someone help me out with this?

Thanks in advanced
Eric
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: question about grep

2003-02-13 Thread Hawley, Eric
I tried what you did suggested and it only pulled out the word Status, here
is the code below;

#location contains the path for the report to be stored
$report_location = $location;
$report_location =~ s/\//\\/;
$report_location = $report_location . \\Reports;
unless( -e $report_location) ){
  mkdir( $report_location ) or die died creating Report Directory;
}
  
#open Report HTML file
open( FILE,  $report_location\\$year_$month_$date_Report.htm ) or die
Dead creating Report;
#print intial html to report file
print FILE
html\nhead\ntitle$year_$month_$date_report/title\n/head\nbody\n
;
  
#file paths include paths to the files, that Status should be greped from
#ex) C:\\Test.htm
foreach $project_file ( @file_paths ){
  #grep Status line from $project_file 
  @status_line = grep /^Status/, $project_file;
}
print FILE /body\n/html\n;
close(FILE);


Hope this can point to any failures.

Thanks
Eric

--

-Original Message-
From: Peter Guzis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 1:33 PM
To: Perl-Win32 (E-mail)
Subject: RE: question about grep


@matches = grep /^Status/, @data;

If this doesn't do it you might consider posting some sample data.

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-Original Message-
From: Hawley, Eric [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 10:23 AM
To: Perl-Win32 (E-mail)
Subject: question about grep


I got a question concerning grep.  I would like to use it to pull out all
full lines of text, that starts with the word Status, from a list of
files.  I am not really too experienced with using Metacharacters and
Metasymbols and do not know how to go about doing this with grep.  Can
someone help me out with this?

Thanks in advanced
Eric
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Install SSL support for Windows?

2003-02-13 Thread Randy Kobes
On Thu, 13 Feb 2003, Frazier, Joe Jr wrote:

 Thanks Randy, that worked.  I guess my guess my biggest gripe
 is Windows has enough of its own quirks, why can't windows
 users easily find the binaries they need to use free software
 modules.  (ie, if a module requires a dll, either include it or
 tell people how to get it.).

Hi Joe,
   You're welcome ... Actually, ppm does have the capability to
run a post-install script (after installation on the Perl side)  
for doing things just like this ... What I've now done is add
such a script to the Crypt-SSLeay package which will offer to
fetch and install the dlls for you, if you don't already have
them. Please let me know if there's any problems with this 

-- 
best regards,
randy

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: question about grep

2003-02-13 Thread fezwang robot
Do you want to pull out lines FROM files, or from a list of files?

e.g.: to print a list of lines beginning with 'my' from a directory of perl 
scripts:

while (*){
   open IN, $_;
   @matches = grep {/^my/} IN;
   close IN;
}

print @matches


HTH


From: Hawley, Eric [EMAIL PROTECTED]
To: 'Peter Guzis' [EMAIL PROTECTED],  Perl-Win32 \(E-mail\) 
[EMAIL PROTECTED]
Subject: RE: question about grep
Date: Thu, 13 Feb 2003 13:49:20 -0500

I tried what you did suggested and it only pulled out the word Status, here
is the code below;

#location contains the path for the report to be stored
$report_location = $location;
$report_location =~ s/\//\\/;
$report_location = $report_location . \\Reports;
unless( -e $report_location) ){
  mkdir( $report_location ) or die died creating Report Directory;
}

#open Report HTML file
open( FILE,  $report_location\\$year_$month_$date_Report.htm ) or die
Dead creating Report;
#print intial html to report file
print FILE
html\nhead\ntitle$year_$month_$date_report/title\n/head\nbody\n
;

#file paths include paths to the files, that Status should be greped from
#ex) C:\\Test.htm
foreach $project_file ( @file_paths ){
  #grep Status line from $project_file
  @status_line = grep /^Status/, $project_file;
}
print FILE /body\n/html\n;
close(FILE);


Hope this can point to any failures.

Thanks
Eric

--

-Original Message-
From: Peter Guzis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 1:33 PM
To: Perl-Win32 (E-mail)
Subject: RE: question about grep


@matches = grep /^Status/, @data;

If this doesn't do it you might consider posting some sample data.

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com

-Original Message-
From: Hawley, Eric [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 10:23 AM
To: Perl-Win32 (E-mail)
Subject: question about grep


I got a question concerning grep.  I would like to use it to pull out all
full lines of text, that starts with the word Status, from a list of
files.  I am not really too experienced with using Metacharacters and
Metasymbols and do not know how to go about doing this with grep.  Can
someone help me out with this?

Thanks in advanced
Eric
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: question about grep

2003-02-13 Thread Hawley, Eric
 actually I think I see what is wrong with the code.  At first I was reading
the wrong variable which was producing just the word Status and second
after looking at the grep function again it looks as though I will have to
store the file into a data structure and grep from that data structure to
get the desired results.

Thanks for your input
Eric

-Original Message-
From: Peter Guzis
To: Perl-Win32 (E-mail)
Sent: 2/13/03 1:32 PM
Subject: RE: question about grep

@matches = grep /^Status/, @data;

If this doesn't do it you might consider posting some sample data.

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-Original Message-
From: Hawley, Eric [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 10:23 AM
To: Perl-Win32 (E-mail)
Subject: question about grep


I got a question concerning grep.  I would like to use it to pull out
all
full lines of text, that starts with the word Status, from a list of
files.  I am not really too experienced with using Metacharacters and
Metasymbols and do not know how to go about doing this with grep.  Can
someone help me out with this?

Thanks in advanced
Eric
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: question about grep

2003-02-13 Thread Alistair . McGlinchy
Eric

I'm in a pretty-code-mode at the moment, my  apologies for the overkill.

 #location contains the path for the report to be stored
 $report_location = $location;
 $report_location =~ s/\//\\/;
To make this regex look a bit better you can use a different delimiter
rather than /. Also you probably want to replace all \ chars with / in
which case you need a 'g' at the end to make it a global replacement. Perl
has a much faster construct for replacing one character with another, i.e.
tr.

$report_location =~ s!\/!\\!g;  # better
$report_location =~ tr!\\!//!;  # best;

See perlop for more info on s and tr

 $report_location = $report_location . \\Reports;

A more explicit way of saying this using the .= construct. It saves you
having to double check that your left hand side is exactly the same as you
right hand side. It seems trivial here but is a godsend when debugging
something like $x[10101]{$y[101]]}= $x[10101]{$y[101]]} + $y[101];

$report_location.=\\Reports  

 unless( -e $report_location) ){
   mkdir( $report_location ) or die died creating Report Directory;
 }
The -e operator tells you that a file exists. We have inherited from Unix
that a directory is a file. You might also want to check that
$report_location exists and is a directory. Id also suggest being a little
more informative to your users. Tell them what went wrong with the $!
variable. Also the idiom _this_ or _that_ can be IMHO elegantly extended
here 

-d $report_location or
mkdir $report_location  or 
die died creating Report Directory '$report_location': $!;

 #open Report HTML file
 open( FILE,  
 $report_location\\$year_$month_$date_Report.htm ) or die
 Dead creating Report;

Note that perl will interpret this as $year_.$month_ etc. You probably
called your variables $year $month etc. So, to force perl to recognise where
the end of you variables are use {}'s. Make sure you put use strict; at
the top of your code and my all your variables otherwise perl will
silently evaluate them to .

my $report_name=$report_location\\${year}_${month}_${date}_Report.htm;
open  FILE, $report_name) or 
die Cannot write to $report_name : $!;

 #print intial html to report file
 print FILE
 html\nhead\ntitle$year_$month_$date_report/title\n/h
 ead\nbody\n
 ;

A more elegant construct for printing long strings is the HERE  syntax 

print FILE END_OF_HTML_HEADER;
html
head
title$year_$month_$date_report/title
Etc,
END_OF_HTML_HEADER

snip

 foreach $project_file ( @file_paths ){
   #grep Status line from $project_file 
   @status_line = grep /^Status/, $project_file;
 }

Note, $project_file will be a file name, not the contents of that file. You
need to open it and read :
foreach my $project_file ( @file_paths ){
open  PROJFILE, $project_file or die Cannot read $project_file :
$!;
my @status_lines = grep /^Status/,  PROJFILE; # Using the file in
an array context;
close PROJFILE;
DoStuff(@status_lines);
}

HTH


Alistair


---


Registered Office:
Marks  Spencer p.l.c
Michael House, Baker Street,
London, W1U 8EP
Registered No. 214436 in England and Wales.

Telephone (020) 7935 4422 
Facsimile (020) 7487 2670

www.marksandspencer.com

Please note that electronic mail may be monitored.

This e-mail is confidential. If you received it by mistake, please let us know and 
then delete it from your system; you should not copy, disclose, or distribute its 
contents to anyone nor act in reliance on this e-mail, as this is prohibited and may 
be unlawful.

The registered office of Marks and Spencer Financial Services PLC, Marks and Spencer 
Unit Trust Management Limited, Marks and Spencer Life Assurance Limited and Marks and 
Spencer Savings and Investments Limited is Kings Meadow, Chester, CH99 9FB.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: question about grep

2003-02-13 Thread Dial Joe

I'm gonna de-lurk for this one.
If you look at Peter's example, you will note that grep applies a block-or-something 
to a list and returns a list.
You are applying it to the file name, not the contents.  Perl grep doesn't read files.
If this wasn't the win32 perl list, I would just advise that you really want the 
shell's grep 
[ like $lines = `grep ^Status $project_file` to get the Status line(s) from one file 
]

Strictly within perl, you would need to open the file and snarf in its contents  to 
grep.
Maybe it would look like this (off the cuff, if errors, please point them out, to add 
value for readers):

 open (IFILE, $project_file ) or die useful message here:$!;
 @lines = grep /^Status/, IFILE;
 close (IFILE);
 #  At this point, @lines has all the lines from $project_file that start with Status.
 #  If these files are HUGE, it might be better to roll your own match loop with while 
(IFILE) {...}

HTH,
Joe Dial


-Original Message-
From: Hawley, Eric [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, February 13, 2003 1:49 PM
To: 'Peter Guzis'; Perl-Win32 (E-mail)
Subject: RE: question about grep


I tried what you did suggested and it only pulled out the word Status, here
is the code below;

#location contains the path for the report to be stored
$report_location = $location;
$report_location =~ s/\//\\/;
$report_location = $report_location . \\Reports;
unless( -e $report_location) ){
  mkdir( $report_location ) or die died creating Report Directory;
}
  
#open Report HTML file
open( FILE,  $report_location\\$year_$month_$date_Report.htm ) or die
Dead creating Report;
#print intial html to report file
print FILE
html\nhead\ntitle$year_$month_$date_report/title\n/head\nbody\n
;
  
#file paths include paths to the files, that Status should be greped from
#ex) C:\\Test.htm
foreach $project_file ( @file_paths ){
  #grep Status line from $project_file 
  @status_line = grep /^Status/, $project_file;
}
print FILE /body\n/html\n;
close(FILE);


Hope this can point to any failures.

Thanks
Eric

--

-Original Message-
From: Peter Guzis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 1:33 PM
To: Perl-Win32 (E-mail)
Subject: RE: question about grep


@matches = grep /^Status/, @data;

If this doesn't do it you might consider posting some sample data.

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-Original Message-
From: Hawley, Eric [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 10:23 AM
To: Perl-Win32 (E-mail)
Subject: question about grep


I got a question concerning grep.  I would like to use it to pull out all
full lines of text, that starts with the word Status, from a list of
files.  I am not really too experienced with using Metacharacters and
Metasymbols and do not know how to go about doing this with grep.  Can
someone help me out with this?

Thanks in advanced
Eric
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: question about grep

2003-02-13 Thread Alistair . McGlinchy
Eric,

 -Original Message-
 From: Hawley, Eric [mailto:[EMAIL PROTECTED]] 
  actually I think I see what is wrong with the code.  At 
 first I was reading the wrong variable which was producing 
 just the word Status and second after looking at the grep 
 function again it looks as though I will have to store the 
 file into a data structure and grep from that data structure 
 to get the desired results.

There is, however, a really nice feature of the magical diamond  that
can help you. If you're writing one-shot code it can be a real time saver,
but should not be used in production code as it's mostly silent when things
go wrong.

# pretend we got a whole load of lines from the command line
@ARGV=*.txt; 
# grep the magical  
my @results = grep /^Status/, ; 

As if by magic...


Alistair


---


Registered Office:
Marks  Spencer p.l.c
Michael House, Baker Street,
London, W1U 8EP
Registered No. 214436 in England and Wales.

Telephone (020) 7935 4422 
Facsimile (020) 7487 2670

www.marksandspencer.com

Please note that electronic mail may be monitored.

This e-mail is confidential. If you received it by mistake, please let us know and 
then delete it from your system; you should not copy, disclose, or distribute its 
contents to anyone nor act in reliance on this e-mail, as this is prohibited and may 
be unlawful.

The registered office of Marks and Spencer Financial Services PLC, Marks and Spencer 
Unit Trust Management Limited, Marks and Spencer Life Assurance Limited and Marks and 
Spencer Savings and Investments Limited is Kings Meadow, Chester, CH99 9FB.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: help reading file url loop

2003-02-13 Thread Malcolm Debono
Thank you Bill.

Can I ask (trying to understand, reading the docs and lama book).
My understanding is that Keys is the $url and the Value is the title which
in my presumption is stored in $links
of $links{$url} = $1;
I don't understand the $1. Confused here?? how are the keys and values
passed to the %links, are both keys  values stored in $1.

If so then is it then possible for other criteria such as
$links{$url} = '';
 if ($content =~ /whatever[^]*\s*(.*)\s*\/whatever/i) {
 $links{$url} = $2;

Any help is appreciated.

Malcolm
- Original Message -
From: $Bill Luebkert [EMAIL PROTECTED]
To: Malcolm Debono [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, February 13, 2003 1:31 AM
Subject: Re: help reading file url  loop


 Malcolm Debono wrote:
  Hello,
  Can someone please help.
 
  I am trying to get my script to read url's from a file and loop through.
I
  can run the script from a form reading the
  my $url = param('url');  (but it will take to long). The code below will
  loop but it doesn't seem to get the url and read the title. I am not
very
  experienced so please explain as simple as possible.


 This should take care of reading the file, retrieving the URLs found
 in the file and printing URL/Title to file and browser.  Not sure what
else
 you wanted to do.

 use strict;

 print Content-type: text/html\n\n;

 my $lockit = 0;   # change to 1 for file locking leave as 0 on windows

 # Absolute path to extract.dat file:
 my $outfile = /Inetpub/wwwroot/cgi-bin/extracthtml/extract.dat;

 # Absolute path to list.dat file:
 my $infile = /Inetpub/wwwroot/cgi-bin/extracthtml/list.dat;

 my %links = (); # store URLs and assoc titles

 open PAGE, $infile or die Can't open $infile: $!;
 while (PAGE) {
 chomp;
 next if not /http/i;
 getinfo ($_);
 }
 close PAGE;

 print htmlheadtitleURLs and Titles/title/head\n;

 # save URLs and titles to file and output to browser

 open OUT, $outfile or die Open $outfile: $!;
 flock (OUT, 2) if $lockit;
 foreach my $url (keys %links) {

 print OUT $url\n;
 print OUT $links{$url}\n;
 print OUT --\n;
 print BRBRBURL: $url/B\n;
 print BRBTitle: ;
 if ($links{$url}) {
 print $links{$url};
 } else {
 print qq{font color=#FFNo Title on Page/font};
 }
 print /B\n;
 }
 close OUT;

 exit;


#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -

 sub getinfo {
 my $url = shift;
 use LWP::Simple 'get';

 my $content = get ($url);
 return 0 if not $content;

 $links{$url} = '';
 if ($content =~ /title[^]*\s*(.*)\s*\/title/i) {
 $links{$url} = $1;
 }

 }


#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -

 sub dienice {
 my $msg = @_;

 print h2Error/h2\n;
 print $msg;
 exit;

 }

 __END__

 --
,-/-  __  _  _ $Bill Luebkert   ICQ=162126130
   (_/   /  )// //   DBE Collectibles   Mailto:[EMAIL PROTECTED]
/ ) /--  o // //  http://dbecoll.tripod.com/ (Free site for Perl)
 -/-' /___/__/_/_ Castle of Medieval Myth  Magic
http://www.todbe.com/


 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: help reading file url loop

2003-02-13 Thread michael higgins


- Original Message -
From: $Bill Luebkert [EMAIL PROTECTED]
To: Malcolm Debono [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, February 13, 2003 1:31 AM
Subject: Re: help reading file url  loop




Malcolm Debono wrote:


Hello,
Can someone please help.

I am trying to get my script to read url's from a file and loop through.



I


can run the script from a form reading the
my $url = param('url');  (but it will take to long). The code below will
loop but it doesn't seem to get the url and read the title. I am not



very


experienced so please explain as simple as possible.



[snip]


Malcolm Debono wrote:
 Thank you Bill.

 Can I ask (trying to understand, reading the docs and lama book).
 My understanding is that Keys is the $url and the Value is the title 
which
 in my presumption is stored in $links
 of $links{$url} = $1;
 I don't understand the $1. Confused here?? how are the keys and values
 passed to the %links, are both keys  values stored in $1.

 If so then is it then possible for other criteria such as
 $links{$url} = '';
  if ($content =~ /whatever[^]*\s*(.*)\s*\/whatever/i) {
  $links{$url} = $2;

 Any help is appreciated.

 Malcolm

Malcolm --

The $1, $2, ...$9 are the capture buffers represented by the parens in 
the regex, so, if you were capturing some other element in a later 
parenthetical expression, *it* would be $2, and so on.

So, your example will give you empty values.

Try perldoc perlre on your machine?


 The bracketing construct ( ... ) creates capture buffers. To refer to
 the digit'th buffer use \digit within the match. Outside the match use
 $ instead of \. (The \digit notation works in certain
 circumstances outside the match. See the warning below about \1 vs $1
 for details.) Referring back to another part of the match is called a
 *backreference*.

 There is no limit to the number of captured substrings that you may use.
 However Perl also uses \10, \11, etc. as aliases for \010, \011, etc.
 (Recall that 0 means octal, so \011 is the character at number 9 in your
 coded character set; which would be the 10th character, a horizontal tab
 under ASCII.) Perl resolves this ambiguity by interpreting \10 as a
 backreference only if at least 10 left parentheses have opened before
 it. Likewise \11 is a backreference only if at least 11 left parentheses
 have opened before it. And so on. \1 through \9 are always interpreted
 as backreferences.

 Examples:

 s/^([^ ]*) *([^ ]*)/$2 $1/; # swap first two words

  if (/(.)\1/) { # find first doubled char
  print '$1' is the first doubled character\n;
  }

 if (/Time: (..):(..):(..)/) {   # parse out values
 $hours = $1;
 $minutes = $2;
 $seconds = $3;


-- Mike Higgins


 ^ ^
-|-
 (.)__ the world is a big box of paints.
__ __  and others, the canvas we're dealt.
 | | -  XTC
_/ \_

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Q XML-Parser upgrade

2003-02-13 Thread John
This morning I updated some XML modules. When I upgraded XML::Parser I
got the following warning as part of the activity log.

[quote]
PPM verify --location=. --upgrade XML::Parser
Upgrade package 'XML-Parser'? (y/N): y
Cannot forceunlink
E:/!PRG/Perl/Perl56\site\lib\auto\XML\Parser\Expat\Expat.dll:
 Permission denied at E:/!PRG/Perl/Perl56/site/lib/PPM.pm line 572
Installing %PERLDIR%\site\lib\auto\XML\Parser\Expat\Expat.bs
Installing %PERLDIR%\site\lib\auto\XML\Parser\Expat\Expat.dll
Installing %PERLDIR%\site\lib\auto\XML\Parser\Expat\Expat.exp
Installing %PERLDIR%\site\lib\auto\XML\Parser\Expat\Expat.lib
[...]
Writing %PERLDIR%\site\lib\auto\XML\Parser\.packlist
Package XML-Parser upgraded to version 2,31,0,0
[/quote]

PPM then opened a console window and requested permision to save
win32_expat.dll in the Perl\bin directory.

This win32_expat.dll is older (by filedate) than
%PERLDIR%\site\lib\auto\XML\Parser\Expat\Expat.dll.

Could someone please explain what happened? and can I safely delete
win32_expat.dll now that the instance of PPM/Perl that performed the
upgrade has completed, or must I keep it forever?

(ActiveState Perl v5.6.1.633, PPM v2.1.6)


--
Regards
   John McMahon  (mailto:[EMAIL PROTECTED])




___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Greetings...

2003-02-13 Thread Emo1313

Greetings,

Welp, I have had no luck getting a Perl FTP server
running... So what I am looking for and perhaps one of you guys can help
me out is; An FTP server application that I can use Perl to add and
remove users, set up where there directories are and perhaps even
quotas... At the least just being able to add users via a perl script.
Like, if a users fills out a form, they can
automatically be added to an FTP servers user list...

Thanks go out to the people who replyed to my questions
about a win32 perl ftp server... 

Thanks for your time!
T.S.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Win32::OLE Word Search and Replace Script Runs Locally but not as part of CGI

2003-02-13 Thread Donavon Lerman
I have the same program written for Excel that works
fine both locally and part of a CGI 

Here is the Error I get:

Can't call method Content on an undefined value at
c:\scripts\sr.pl line 19. 

Here is the Code:

#!/perl/bin
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Word';

my $oldfile = 'c:\tmp\test.doc';
my $newfile = 'c:\tmp\test1.doc';
my $oldtext = 'change me';
my $newtext = 'I am changed';

my $word =
Win32::OLE-GetActiveObject('Word.Application')
|| Win32::OLE-new('Word.Application','Quit');

my $doc = $word-Documents-Open($oldfile);

# is application visible 0=no  1=yes
$word-{visible} = 0;

my $search =  $doc-Content-Find;
my $replace = $search-Replacement;

$search-{Text} = $oldtext;
$replace-{Text} = $newtext;
$search-Execute({Replace = wdReplaceAll});

# save word file
$word-ActiveDocument-SaveAs($newfile);

# close word file
$doc-Close();
$word-Quit();


__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs