Re: timestamp conversion
My goal is to get element 9 of stat which is mtime. I am getting this with ease, but my end goal is to convert this number back into a readable format giving me how old the file is. So here is a rough draft formula : (time in seconds - last MTime ) = seconds old. Convert seconds old to a human readable time stamp using localtime (); Any ideas or is there a better way? Seconds old to human readable via localtime will give you some funny results (like dates from 1970). If you're looking for days hours minutes seconds old: days = seconds old / seconds in a day seconds left = seconds old % seconds in a day hours = seconds left / seconds in an hour seconds left = seconds left % seconds in a hour minutes = seconds left / seconds in a minute seconds = seconds left % seconds in a minute ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Encrypt a file, was Re: Encrpt a file
On Mon, 18 Apr 2005, Anish Kumar K wrote: Can [anyone] suggest a good algorithm for [encrypting] and [decrypting] files ..I donot want to use any perl module for that... Check out the perl stuff on this site. I haven't actually used it yet, though I've been meaning to look at it. But their Java stuff is really good. http://www.cryptix.org/ Not sure why you don't want to use a module, but you could always pull out the parts you need. ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Request for regex: Strip last dash in a record
Hi All, The code below does what I want to do, but it takes 3 lines and a temporary array (yuck). I can't come up with a one line regex substitution. Anyone got one? my $tmp = reverse split //, $_; $tmp =~ s/-//; $_ = reverse split //, $tmp; TIA, Peter ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Request for regex: Strip last dash in a record
[EMAIL PROTECTED] wrote: Hi All, The code below does what I want to do, but it takes 3 lines and a temporary array (yuck). I can't come up with a one line regex substitution. Anyone got one? my $tmp = reverse split //, $_; $tmp =~ s/-//; $_ = reverse split //, $tmp; can you post a sample string which you want to substitute.. sure. Example record: 0-0-0-EXAMPLE-00-621 Will become: 0-0-0-EXAMPLE-00621 - Peter ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Request for regex: Strip last dash in a record
If you just want to remove the last occuring '-' character, then the following would work. s/(.*)-(.*)/$1$2/; Well, huh. That does work. Though it reminds me only of how little I understand why. Thanks, you've made it look easy. ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Does the SWITCH statement have a default?
Is there a correct way to define a default case within a SWITCH? I tried with the bottom case, but that errors with: Quantifier follows nothing before HERE mark in regex m/* HERE / at ./ctest line 251. SWITCH: { $field =~ /^CR\d{0,7}$/ do { $openCRs++; print tda href=\/cgi-bin/ctest?repOn=CRcrNumber =$field\$field/a/td; last SWITCH; }; $field eq $engineer do { print tda href=/cgi-bin/ckEng?$field$field/a/td; last SWITCH; }; $field =~ /*/ do { print td$field/td; last SWITCH; }; } I want to match anything else including an empty field with the last case. Your help is greatly appreciated, thanks. Not to confuse you, but there is no such thing as a SWITCH statment in Perl. Above you have defined a tag to name a block and then set up conditions that if true, runs the code in the do block and exit the SWITCH: block. You could have substituted any tag for SWITCH, though SWITCH does clarify what you're doing. So any code you place after the last do block will execute if there is no match. Actually, to draw on your above style, I think '$field =~ /.*/' should match on anything. Enjoy, Peter ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: pronunciation guide
I thought it was only called 'string' in Applesoft... Glad to hear I'm not the only one. My co-workers think I'm crazy. |-+ | | Paul Kraus | | | [EMAIL PROTECTED]| | | .com| | || | | 08/25/2003 09:02 | | | AM | | | Please respond to| | | pkraus | | || |-+ --| | | | To: 'Paul Archer' [EMAIL PROTECTED], [EMAIL PROTECTED] | | cc: | | Subject: RE: pronunciation guide | --| Not sure how to help you I do not that it is not very common to refer to $ as dollar unless your talking about dollars. Generally when dealing with computers it is a representation of the word string and is spoken as such. String-underscore. -Original Message- From: Paul Archer [mailto:[EMAIL PROTECTED] Sent: Monday, August 25, 2003 8:08 AM To: [EMAIL PROTECTED] Subject: pronunciation guide Does anyone know of a pronunciation guide for the special variables and such in Perl? I came up empty on Google. I've been learning Perl by reading and doing, but I haven't talked to anyone face-to-face, so I'm not sure, for example, if $_ is spoken dollar-underscore, or if people typically say something else--like = is a spaceship, or #! is a shebang. Paul -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: trouble with math... driving me nuts.
This seems to work, although there are some odd line returns and '0' is being returned as '0.' Still, I can work around that, THANKS! |-+ | | zsdc [EMAIL PROTECTED]| | || | | 08/21/2003 03:28 | | | PM | | || |-+ --| | | | To: [EMAIL PROTECTED] | | cc: [EMAIL PROTECTED] | | Subject: Re: trouble with math... driving me nuts. | --| [EMAIL PROTECTED] wrote: print 37.75 - 33.67 - 4.08 ; STDIN; I find these things all the time. Is there a particular module I can use to fix these things? Take a look at Math::BigFloat, it's an arbitrary length float math package: #!/usr/bin/perl -wl use Math::BigFloat; $x = 37.75; print $x - 33.67 - 4.08; $x = Math::BigFloat-new('37.75'); print $x - 33.67 - 4.08; ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. OK, I won't tell anyone. -zsdc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: trouble with math... driving me nuts.
True, it's not a Perl issue (I've been able to duplicate the problem in C, and Scheme), but I'm looking for a Perl solution. Math::BigFloat seems to work well enough. Thanks, Peter |-+ | | Levon Barker | | | [EMAIL PROTECTED] | | || | | 08/21/2003 03:09 | | | PM | | || |-+ --| | | | To: [EMAIL PROTECTED], [EMAIL PROTECTED] | | cc: | | Subject: RE: trouble with math... driving me nuts. | --| Hi Peter, This is a floating point issue. It is a general computing problem and not just subject to Perl. In decimal form the result is -0.0017763568. Generally thats usually acurate enough. Otherwise you could truncate it or round it to the nearest quadrabillionth. Cheers, Levon Barker -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, August 21, 2003 3:06 PM To: [EMAIL PROTECTED] Subject: trouble with math... driving me nuts. Luckily I was easily able to recreate the problem. See code below: print 37.75 - 33.67 - 4.08 ; STDIN; I find these things all the time. Is there a particular module I can use to fix these things? Output is -1.77635683940025e-015 Should be 0 Running on Win2000 / Intel P3 -Peter ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
trouble with math... driving me nuts.
Luckily I was easily able to recreate the problem. See code below: print 37.75 - 33.67 - 4.08 ; STDIN; I find these things all the time. Is there a particular module I can use to fix these things? Output is -1.77635683940025e-015 Should be 0 Running on Win2000 / Intel P3 -Peter ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: trouble with math... driving me nuts.
Hi Bob, I'm doing data-processing (EDI). I need to format and present values in text, round here and there. Have lots of various attempts that have failed for one math related reason or another. Currently I convert to a string and split and round, etc. (Even modulo '%' has failed me at times). So this 0 comes across as -1.78. Tried printf(%.02f, $value) and got -0.00 back (negative 0?), so I'm not trusting that route much. The documentation you refered me to (which didn't work on 2000, but luckily I keep my Linux laptop near me at all times) refers to Math::BigFloat. If you can think of a better package I'd go that route though. Thanks, Peter P.S. Things are a little crazy here, so I'm getting chatty. Sorry if there's too many words above. |-+--- | | Bob Showalter | | | [EMAIL PROTECTED]| | | rwhite.com | | | | | | 08/21/2003 03:18 PM | | | | |-+--- --| | | | To: '[EMAIL PROTECTED]' [EMAIL PROTECTED], [EMAIL PROTECTED] | | cc: | | Subject: RE: trouble with math... driving me nuts. | --| [EMAIL PROTECTED] wrote: Luckily I was easily able to recreate the problem. See code below: print 37.75 - 33.67 - 4.08 ; STDIN; I find these things all the time. Is there a particular module I can use to fix these things? Output is -1.77635683940025e-015 Should be 0 That is zero, within the limits of the precision of floating point numbers. Read the faq article: perldoc -q 'long decimals' There are a number of modules on CPAN that go beyond the FAQ to address this issue. What are you trying to do? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How do I check disk space through Perl?
Hi All, It seems like I should know this, but I don't, and I can't seem to find it written anywhere. I need to check disk space on an NT platform using ActiveState Perl 5.6.1. Is there an easy way to do this? Thanks, Peter ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Net::FTP in Passive mode hangs and fails (really frustrating)
Hi David, I'm using Active State 5.6.1 build 631 on NT 4. This problem appears to be connected to the level of network traffic. But two things stand out. The files are on average only 12K, and the previous process had it's problems, but not this one. It was running on the same box, but was using JAL (a horrible language to code in for anything over 3 lines) in the 24x7 scheduler. When the transfers work (which I'm glad to see they have been all night) they only take seconds. Thanks, Peter |-+ | | David O'Dell | | | [EMAIL PROTECTED]| | | .com| | || | | 04/02/2003 06:30 | | | PM | | || |-+ --| | | | To: [EMAIL PROTECTED] | | cc: | | Subject: Re: Net::FTP in Passive mode hangs and fails (really frustrating) | --| Are you using this on a unix or NT box? The reason I ask is that I a similar script running on both a linux and an NT box. On the linux box the transfers (both put and get) are fine but on my NT box it drags on forever. 5 minutes on linux and over an hour on NT. [EMAIL PROTECTED] wrote: Hi All, I'm unsure what to do next. I hope someone has beaten this before and hears my cry for help. I've implemented a script to transfer files to a client, and to pick files up. There is a firewall, though I don't know much about it. I instantiate the Net::FTP object with Passive = 1. The transfers are running several times a day. Some of them are hanging. The client may get a zero byte file before the process drops. We may get the file, but the job wont recognize this and errors out. I know that's a pretty vague description of the problem, but I don't know much more to add. The scripts are really very simple. In essence: my $ftp = Net::FTP-new($server, Passive = 1); $cnt = 0; while( ! $ftp-login($login, $password) ){ $cnt++; if ( $cnt = 3 ){ # error handling stuff exit -1; } sleep (2); } $ftp-binary; $cnt = 0; while ( ! $ftp-put($localfile,$remotefile)){ $cnt ++; if ( $cnt = 3 ){ # error handling stuff exit -2; } sleep (2); } $cnt = 0; while (! $ftp-ls($remotefile) ){ $cnt++; if ( $cnt = 3 ){ # error handling stuff exit -3; } sleep (2); } $ftp-quit(); In this case a put might hang (on the way back it's the get's chance). Not surprisingly, jobs on our intranet have no such problems. Any help welcome! TIA Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Net::FTP in Passive mode hangs and fails (really frustrating)
Hi All, I'm unsure what to do next. I hope someone has beaten this before and hears my cry for help. I've implemented a script to transfer files to a client, and to pick files up. There is a firewall, though I don't know much about it. I instantiate the Net::FTP object with Passive = 1. The transfers are running several times a day. Some of them are hanging. The client may get a zero byte file before the process drops. We may get the file, but the job wont recognize this and errors out. I know that's a pretty vague description of the problem, but I don't know much more to add. The scripts are really very simple. In essence: my $ftp = Net::FTP-new($server, Passive = 1); $cnt = 0; while( ! $ftp-login($login, $password) ){ $cnt++; if ( $cnt = 3 ){ # error handling stuff exit -1; } sleep (2); } $ftp-binary; $cnt = 0; while ( ! $ftp-put($localfile,$remotefile)){ $cnt ++; if ( $cnt = 3 ){ # error handling stuff exit -2; } sleep (2); } $cnt = 0; while (! $ftp-ls($remotefile) ){ $cnt++; if ( $cnt = 3 ){ # error handling stuff exit -3; } sleep (2); } $ftp-quit(); In this case a put might hang (on the way back it's the get's chance). Not surprisingly, jobs on our intranet have no such problems. Any help welcome! TIA Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to map hash keys only, not values?
Hi Joseph, Probably just as well. Is there some context where you anticipate having to repair broken keys after the fact? In this case I'm building packages, and don't want to count on the user to get the case of the text correct when passing the values. So if I need to set the 'smile' attribute in one call and reference it in another, I want it to be 'SMILE', even if I or someone else passes it as 'Smile'. example: if ($values{SMILE}){ $sql .= and SMILE = '. $values{SMILE} .'; } If I need to select based on the smile field, I want to be able to call the function doing this without worrying about case, or the order in which the values are being passed. @eyes = get_eyes( smile = BIG, Laughs = 5 ); same as: @eyes = get_eyes( laughs = 5, SMILE = BIG ); -Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to map hash keys only, not values?
Hi All, I'm passing a hash to a subroutine like this: subname(a = 123, b =fff, C = joyjoyjoy); On the receiving side I want all keys to be upper case. I can map like this: sub subname{ map {$_ =~ tr/a-z/A-Z/} @_; my %values = @_; .. } and I can live with that I guess. But really I just want to push the keys, not the values, into upper case. Is there a way to just map the keys? I can't think of one. TIA, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to map hash keys only, not values?
First, please don't use map in a void context for its side effects. Uh oh... What side effects? I use map like this all the time! What dread is looming in my future? Just loop it: sub subname { my %values; while (@_ = 2) { my ($key, $value) = splice @_, 0, 2; $values{uc $key} = $value; } ... } Thanks! As is often the case, it looks obvious now that I see it. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to map hash keys only, not values?
Replace EVIL: map { some;block;of;code;that;changes;$_ } @some_array; with GOOD: for (@some_array) { some;block;of;code;that;changes;$_ } I guess I don't get it. Map returns a value and I ignore it; so what? What side effects does this have? Which one's faster? I like to avoid obvious loops when possible because I perceive them as slow, so I often use map, and rarely (actually, to date, never) care about the return value. If there's no savings then I guess it doesn't matter. But what makes it bad? Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to map hash keys only, not values?
The foreach loop *will* be faster. Good enough for me! Thanks, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to concat files easily?
use File::Slurp $file1 = read_file($fileone); $file2 = read_file($filetwo); write_file($filenew,$file1\n$file2) Thanks Dan, It's that easy! -Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how to concat files easily?
Hi All, Sorry if this is a stupid question. It took me awhile to figure out I could use the File::Copy module to copy a file, and this is about the same level of ignorance. Is there an easy way to concatenate two (text) files in Perl, short of opening two to read and one to write and then loop loop looping the two input files into the output file? TIA, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Win32::Process question
Hi All, I'm hoping someone has done this before. I need to spawn 3 processes and then wait for all three to finish. spawn like this: my $obj; my $appname = $perl; my $cmdline = $deliverscript $arg; my $iflags = 1; my $cflags = CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS; my $curdir = $localdir{$filetype}; my $Result1 = Win32::Process::Create( $obj1,$appname,$cmdline,$iflags,$cflags,$curdir ); my $Result2 = Win32::Process::Create( $obj2,$appname,$cmdline,$iflags,$cflags,$curdir ); my $Result3 = Win32::Process::Create( $obj3,$appname,$cmdline,$iflags,$cflags,$curdir ); but how can I tell when all three are finished? If I use $obj1-Wait(INFINITE); $obj2-Wait(INFINITE); $obj3-Wait(INFINITE); what happens if $obj2 finishes before $obj1? is there a way to check and see if a process ($obj1,$obj2,$obj3) is still running? Then I could try something like: while (1){ if ($obj-status and $obj-status and $obj-status) {last;} sleep (.2); } TIA, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: Win32::Process question
but how can I tell when all three are finished? If I use $obj1-Wait(INFINITE); $obj2-Wait(INFINITE); $obj3-Wait(INFINITE); what happens if $obj2 finishes before $obj1? looks like this works fine... PHF -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic Hash Naming and multi-dimensional hashes
I've played tag the wall with the forehead long enough. a) a way to name a hash from user input If you mean assign a value with in a hash using the user input, then: my %hash $key = STDIN; $val = STDIN; $hash{$key} = $val; If you really want to let the user name your variables for you (which you probably really don't want), you would use eval; $hashname = STDIN; eval (\$$hashname;); don't do that though... b) find a way to create a multi-level hash (hash within a hash) This is done with references. They only seem hard at first. here's a hash: %happy_hash = ( smile = :), bigger= :D, ); here's another: %another_hash = ( far = Look over There!, near = Look at this!, ); now here's a third that holds the first two: %big_hash = ( happy = \%happy_hash, another = \%another_hash, ); the back slash means that the variable refers to the hash, but is not really the hash. This way you get a scalar (which is what hashes are made of), but you can use it to get to the hash. here's one syntax to get to the hash: $big_smile = ${$big_hash{happy}}{bigger}; # you can probably get away with $big_hash{happy}{bigger}, # and it doesn't look as confusing, but I use the previous syntax. $big_hash{happy} returns the reference to the happy_hash, just as this would assign it to a scalar: $hrHappy = $big_hash{happy}; To dereference this to the hash is %{$big_hash{happy}}. Just wrap the scalar in braces and stick the appropriate symbol on front ($%@*) for $hrHappy it's %{$hrHappy} Now you can access the value in the hash; just like a regular hash, but with a weird lookin' name. The syntax is $hashname{key}, so here it's ${$big_hash{happy}}{bigger} or ${$hrHappy}{bigger}, both of which return $happy_hash{bigger}, which is :D Ofcourse, why put hashes that have names in other hashes unless you have a good reason? So there are anonymous hashes. They look like this: {smile = :), bigger = :D} and you can assign them just like a hash reference: %big_hash = ( happy = { smile = :), bigger= :D, }, another = { far = Look over There!, near = Look at this!, }, ); and create them on the fly too: ${$big_hash{onion}}{burger} = beefy; ${$big_hash{onion}}{ring} = greasy; $big_hash{foul} = {bird = duck, ball = strike}; And hopefully code that looked illegible before is starting to make some sense. #Create a multi-dimensional array same thing: @big_arr = ([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]); even: @hash_arr = (\%hash1, \%hash1, \%hash1); or: @mixed_arr = (\%hash1, [EMAIL PROTECTED], \%big_hash, [EMAIL PROTECTED]); There are lots of fun ways to build data structures using references. You can create anonymous subroutines too, and put those in a hash. HTH -Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling a subroutine as an element of a hash table...
Thanks to all who replied. |-+ | | Rob Dixon | | | [EMAIL PROTECTED]| | | m.co.uk | | || | | 02/07/2003 05:09 | | | PM | | || |-+ --| | | | To: [EMAIL PROTECTED] | | cc: | | Subject: Re: calling a subroutine as an element of a hash table... | --| Peter Farrar wrote: Hi All, I swear I've called subroutines this way before, but I can't find any examples. In this case, I'm looking to build some time/date functions. Regardless of what the actual code is supposed to do, the calling of subroutines as elements of a hash is causing me grief. I am receiving the following message: Undefined subroutine main:: called at D: \perldev\workroom\dates\dates.pl line 16. Here is the code. Can anyone see what I am doing wrong here??? I'm afraid this is mainly just another use strict; rant. You have three different hashes in use. Look: %date_formats = ( 1) %date_formats # ccyymmdd = {now = \ccyymmdd_now()}, ccyymmdd = {now = sub { my @arr = localtime(); 1900 + $arr[5] . sprintf(%02d,$arr[4] + 1) . sprintf(%02d,$arr[3]); } }, mmdd = {now = ${$formats{ccyymmdd}}{now},}, ); 2) %formats Also, you need a separate statement to defined a key value in terms of another value in the same key. Otherwise you could define recursive hashes! Like this: $date_formats{mmdd}{now} = $date_formats{ccyymmdd}{now}; sub now { my $format = shift; $format =~ tr/A-Z/a-z/; if (exists $date_formats{$format}){ # Not working... {${$date_format{$format}}{now}}(); 3) %date_format Can also be written: $date_formats{$format}{now}(); }else{ print STDERR invalid format\n; } } [snip trailing code] If you'd used strict, you would have had to declare all of those hashes, and would certainly have realised that you were using three independent ones! Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling a subroutine as an element of a hash table...
Oops, hit send by mistake. This problem all seems to be about mistakes... Thanks to all who replied. You have three different hashes in use. Look: I did indeed have 3 hash tables... Duh (Must have been Friday afternoon). The central problem was calling '{${$date_format{$format}}{now}}()' instead of '{${$date_formats{$format}}{now}}()' (note the letter 's' missing from the original). Otherwise you could define recursive hashes! Like this: $date_formats{mmdd}{now} = $date_formats{ccyymmdd}{now}; That's exactly what I was going for! If you'd used strict, you would have had to declare all of those hashes, and would certainly have realized that you were using three independent ones! FYI: My code now begins with 'use strict;' Note: A question as to why the seemingly unnecessary complexity of the structure was raised. This is just a strip down of what I hope to accomplish. It may well be more abstract then necessary, but It made sense to me and was more entertaining than other options. I want a set of subroutines that do basically the same thing for different date formats. And I wanted them to be my own, rather than using 'Date::Comp' or some other existing package because it's just more gratifying that way, more educational, and more specific to my circumstances. The thought is to order subroutines like 'now', 'convert_format', 'subtract_days' etc. by their date formats, then call a single function (like 'now(dd-mon-yy)') that selects the correct version of the routine from the from the table based on the format. Thanks again! Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Comparing Arrays
if (@Af1 eq @Af2) { print Files compare okay\n; } else { print Files differ\n; } # How about something clunky like this: if (join(,@Af1) eq join(,@Af2)) { print Files compare okay\n; } else { print Files differ\n; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
calling a subroutine as an element of a hash table...
Hi All, I swear I've called subroutines this way before, but I can't find any examples. In this case, I'm looking to build some time/date functions. Regardless of what the actual code is supposed to do, the calling of subroutines as elements of a hash is causing me grief. I am receiving the following message: Undefined subroutine main:: called at D: \perldev\workroom\dates\dates.pl line 16. Here is the code. Can anyone see what I am doing wrong here??? TIA, Peter P.S. you can see where I comment out the ccyymmdd_now function. That approach works, but is not what I'm shooting for. %date_formats = ( # ccyymmdd = {now = \ccyymmdd_now()}, ccyymmdd = {now = sub { my @arr = localtime(); 1900 + $arr[5] . sprintf(%02d,$arr[4] + 1) . sprintf(%02d,$arr[3]); } }, mmdd = {now = ${$formats{ccyymmdd}}{now},}, ); sub now { my $format = shift; $format =~ tr/A-Z/a-z/; if (exists $date_formats{$format}){ # Not working... {${$date_format{$format}}{now}}(); }else{ print STDERR invalid format\n; } } #print | . ccyymmdd_now() . |\n; print | . now(ccyymmdd) . |\n; STDIN; sub ccyymmdd_now{ my @arr = localtime(); 1900 + $arr[5] . sprintf(%02d,$arr[4] + 1) . sprintf (%02d,$arr[3]); } __END__ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tk with Perl
Trying it now from the Command Prompt.seems to be just 'sitting' there. Hi Tony, If you're still having trouble getting the package, it could be a firewall issue. I have to download packages, then install from my local box because of corporate B()[[S][|~!. I believe this is the correct URL (though I always have a hard time finding it): http://ppm.activestate.com/PPMPackages/zips/5xx-builds-only/TK.zip download, unzip, move to that dir at command line and install, `ppm install --location=current_directory Tk` should do it IIRC. `Perldoc ppm` should answer any install questions. I'm using ActiveState Perl 5.6.1 build 663 and did have to install this module separately. But you can try `ppm query` to see what's installed. Mine has this line for TK: Tk [800.023] A Graphical User Interface Toolkit Enjoy, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash of Hashes of Arrays?
I have a list of inspection stations in a data file which is comma-separated. It contains the following data, in order: Station Name, Address 1, Address Line 2, City, State, Zip, Phone Number I need to group the lines (of address information) by city and get a count of the number of stations in a given city. OK, I didn't actually test this exact code, but it should present the idea of storing this information in an array of arrays: open IN, yourfile; while (IN){ chomp; push @arr, \[split /,/]; } close IN; @arr = sort ${$arr[$a]}[3] = ${$arr[$b]}[3] @arr; # sort by city How do you picture using a hash of hashes of arrays? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
my struggle to work with structures... pls hlp!
Hi All, I'm playing with record formats. I need to be able to have more than one kind of delimited format available at one time. I've written a sort routine to get the values in the order I want, but it assumes one variable name (in this example that is %delimited format). I want something a little more dynamic. I've tried passing the structure to the sort routine, but it wont play along. Perhaps I'm approaching this all wrong. Perhaps I'm missing something simple. Any ideas how to better handle this? Code example follows: %delimited_format = ( delimiter = |, fields = { field_three = {index = 3,value = THREE}, field_two = {index = 2,value = TWO}, field_one = {index = 1,value = ONE}, field_four = {index = 4,value = FOUR}, field_five = {index = 5,value = FIVE}, }, ); ## this part wont work... #foreach my $fieldname ( sort delim_sort(\%delimited_format) keys % {$delimited_format{fields}}){ # print $fieldname\t; # print ${${$delimited_format{fields}}{$fieldname}}{index}.\t; # print $delimited_format{delimiter}.\n; #} #sub delim_sort{ # my $hRef = shift; # ${${${$hRef}{fields}}{$a}}{index} # = # ${${${$hRef}{fields}}{$b}}{index} #} ## this part will work... foreach my $fieldname ( sort old_delim_sort keys % {$delimited_format{fields}}){ print $fieldname\t; print ${${$delimited_format{fields}}{$fieldname}}{index}.\t; print $delimited_format{delimiter}.\n; } sub old_delim_sort{ ${${$delimited_format{fields}}{$a}}{index} = ${${$delimited_format{fields}}{$b}}{index} } __END__ TIA, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tk with Perl
I have installed Perl 5.6.1 ( which works ) and Tcl/Tk 8.3 ( which works ) on Windows 2000 but when I try to perl -e use Tk I get the following error: Can't locate Tk.pm in @INC ( @INC contains: D:/Perl 5.6.1/lib D:/Perl 5.6.1/site/lib . ) at -e line 1. Have you downloaded and installed the Tk.pm from ActiveState.com? It is not installed with Perl or Tcl by default. The actual module is D:\Perl\site\lib\Tk.pm on my box. YMMV (?). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cc and bcc in Net::SMTP
Hi, The 'cc' and 'bcc' methods in Net::SMTP seem to simply alias the 'to' method. How do I actually 'cc' and 'bcc' in Net::SMTP? I tried putting these in the DATA area (though it doesn't really make sense to me to do it that way). I even looked through RFC 822 and 2821 for hints... but I guess I'm not very good at making sense of RFCs. Any help appreciated. Thanks, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cc and bcc in Net::SMTP
Just like that. Thanks for demystifying that for me. |-+ | | George | | | Schlossnagle| | | [EMAIL PROTECTED]| | | m | | || | | 12/04/2002 03:50 | | | PM | | || |-+ --| | | | To: [EMAIL PROTECTED] | | cc: [EMAIL PROTECTED] | | Subject: Re: cc and bcc in Net::SMTP | --| the Net::SMTP methods implement the SMTP protocol. Net::SMTP::to (and cc and bcc) simply set the data to be passed as a RCPT TO: command. This set's the envelope recipient on a mail, which is how your mta (and others) know who the mail is going to. cc: and bcc: (and things like Date: Message-ID: Subject:. etc.) are body headers. They appear in the body of the mail but are not used for routing information. So these should be done like: $smtp = Net::SMTP-new('mailhost'); $smtp-mail('[EMAIL PROTECTED]'); # set's the envelope from address via the MAIL FROM: protocol directive $smtp-to('[EMAIL PROTECTED]', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]'); # sets the envelope recipient for routing purposes via RCPT TO: directive $data = Subject: This is a test To: you\@yourdomain.com cc: bob\@bobs.com This is the body of my mail; $smtp-data($data); Now you have you as the To: addressee, bob as the cc: and jill is bcc'd. On Wednesday, December 4, 2002, at 03:29 PM, [EMAIL PROTECTED] wrote: Hi, The 'cc' and 'bcc' methods in Net::SMTP seem to simply alias the 'to' method. How do I actually 'cc' and 'bcc' in Net::SMTP? I tried putting these in the DATA area (though it doesn't really make sense to me to do it that way). I even looked through RFC 822 and 2821 for hints... but I guess I'm not very good at making sense of RFCs. Any help appreciated. Thanks, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Programming pipes to and from another program
Hi there, I hope this is a trivial newbie problem: I know how to open a pipe to another program: open (OUT, |perl .\\bogus.pl) or warn Unable to open pipe to bogus.pl\n; print OUT Stuff\n; And I know how to open a pipe from another program: open (IN, perl .\\bogus.pl|) or warn Unable to open pipe from bogus.pl\n; $input = IN; But when I try to do both... open (OUT, |perl .\\bogus.pl) or warn Unable to open pipe to bogus.pl\n; open (IN, perl .\\bogus.pl|) or warn Unable to open pipe from bogus.pl\n; or open (BOGUS, |perl .\\bogus.pl|) or warn Unable to open pipe for bogus.pl\n; strange things happen. Is there a simple (or even complex) way to open a two way pipe to another program with Perl. (I don't want to use Expect or any other scripting language if I can help it). I'm trying to implement batch code for automating processes over night. Some of these require a dialog. TIA Peter ** CONFIDENTIALITY NOTICE ** THIS E-MAIL, INCLUDING ANY ATTACHED FILES, MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION FOR THE SOLE USE OF THE INTENDED RECIPIENT(S). ANY REVIEW, USE, DISTRIBUTION, OR DISCLOSURE BY OTHERS IS STRICTLY PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT (OR AUTHORIZED TO RECEIVE INFORMATION FOR THE RECIPIENT), PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND REMOVE ALL COPIES OF THIS MESSAGE. THANK YOU. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Programming pipes to and from another program
If *nix, look at help for the open3 function. Attached as a text file is the little run class that I use to do this. Here is an example of how to use this class to encapsulate GPG, where the passphrase gets written to stdin of the child process, and the results are reaped from the childs stderr and the decrypted contents from the childs stdin. [snip] Jeff, This is exactly the kind of process I'm having trouble with! PGP encription. Unfortunatly, I'm forced to work on W2K. I haven't had much luck with IPC::Open2, but I'll see if I can adapt this fine code. Thanks for the responce, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Recognizing Directories...
Hello Everyone, I am writing a utility that needs to index the files contained within about 500 directories (some nested). I want to provide the script with a top directory and have it recurse through everything underneath while indexing the files within each. I've searched Google and can't seem to find a way to do this. I know how to get all files within a directory but how do I RECOGNIZE my directories so I can descend into them to index? Thanks in Advance, Anthony Saffer if (-d $val){ #do stuff } look out for long file names when globbing. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
globbing problem with longfilenames containing spaces (Windows)
Hi all, Here is the code I'm having problems with: my @arr = glob($here\\*); foreach $val (@arr){ if (-d $val){ travel_dirs($val, $level-1) if $level 0; }else{print$val\n;} } 'else print $val' is just there for debugging, so I can see whats going on... I have a directory with spaces in the name. @arr is breaking it up into seperate elements, so C:\folder\folder with stuff in it comes across as: C:\folder\folder with stuff in it this is being used in a recersive search. I cant get into the directories with spaces. Any ideas how to get past this? TIA, Peter ** CONFIDENTIALITY NOTICE ** THIS E-MAIL, INCLUDING ANY ATTACHED FILES, MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION FOR THE SOLE USE OF THE INTENDED RECIPIENT(S). ANY REVIEW, USE, DISTRIBUTION, OR DISCLOSURE BY OTHERS IS STRICTLY PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT (OR AUTHORIZED TO RECEIVE INFORMATION FOR THE RECIPIENT), PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND REMOVE ALL COPIES OF THIS MESSAGE. THANK YOU. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to check installed Modules in perl
in windows: ppm query Jaimee Spencer To: 'Alex Cheung Tin Ka' [EMAIL PROTECTED], [EMAIL PROTECTED] JSpencer@acuc cc: orp.com Subject: RE: How to check installed Modules in perl 04/17/2002 12:24 PM Hello Alex, You could run the below perl Script. Hopes this helps. Regards, Jaimee #!/usr/bin/perl # list all of the perl modules installed use File::Find ; for (@INC) { find(\modules,$_) ; } sub modules { if (-d /^[a-z]/) { $File::Find::prune = 1 ; return } return unless /\.pm$/ ; my $fullPath = $File::Find::dir/$_; $fullPath =~ s!\.pm$!!; $fullPath =~ s#/(\w+)$#::$1# ; print $fullPath \n; } -Original Message- From: Alex Cheung Tin Ka [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 16, 2002 11:14 PM To: [EMAIL PROTECTED] Subject: How to check installed Modules in perl Dear All, I am new to perl. I would like to know what can I do to check whether I have installed particular module in perl. Thanks Alex -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: external hashtable
The book from O'Reilly, Perl DBI, chapter 2, has a good look at Data::Dumper and other approaches that could work here. Jonathan E. PatonTo: [EMAIL PROTECTED] jonathanpaton@ cc: yahoo.comSubject: Re: external hashtable 03/18/2002 10:41 AM Ok, I'm on a Linux box here. and I do have Data::Dumper. :) So how would the solution with Dumper work? There is not very much documentation on Dumber in the camel... s/Dumber/the smarter way/; I suggest you search via your favourite search engine, or if you don't mind reading a little: perldoc Data::Dumper To output: print FILE Data::Dumper-Dump(\%hash); Reading might be the same as I showed, don't know. Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl Tk.
I've been growing interested in the Tk module too. I found this today. It's really really introductory. http://www.perl.com/pub/a/1999/10/perltk/ David Samuelsson (PAC) [EMAIL PROTECTED] To: '[EMAIL PROTECTED]' [EMAIL PROTECTED] icsson.se cc: Subject: Perl Tk. 03/15/2002 07:12 AM I am planning to write a litte graphical interface for an application that has a full CLI. Perl Tk, should accomplish this. What i need is more information then the one that is in the perlfaq, i need instructions, faqs,snippets, all i can get, can anyone point me in the right direction for this? Much appriciated. //David -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How long can $_ be?
I've seen this effect when using data I copied off the internet (using Explorer) into a text file in a Unix environment. In my case the problem was definitely a control character within the string causing a line return without a line feed. It didn't show up when I viewed the file with less or cat, or notepad on Windows, just when I manipulated it with perl, and printed the results to the screen. It really drove me crazy for a while. I don't remember exactly what crudgy solution I came up with, but it sounds like the same kind of problem. Anette Seiler To: [EMAIL PROTECTED] SEILER@hbz-nr cc: w.deSubject: RE: How long can $_ be? 03/13/2002 06:51 AM Dear All, the script I'm using is really very simple: script #!/usr/local/bin/perl -w use strict; while () { chomp; print \n\n$_\n\n; } /script From the command line I start the script with perl script.pl. Now I have to enter some text. I just enter any text, either by typing or by cutting and pasting. I do not enter any strange characters or newlines. I just type in some text. I even take care to just use normal characters - no numbers, umlaute or anything else strange. As you can see, I did not play with $/. As I wrote in my initial mail, the answer I get is not the answer I expect. Whenever my input is more than 256 character, instead of printing everything I entered, it prints only the last part of what I entered, everything after character 256. The first part is chopped off. I experimented with that and had the following results: The first line I gave was 490 characters long, $_ contained the last 233 characters. The string was chopped off at character 257. The second line I gave was 462 characters long, $_ contained the last 205 characters. The string was chopped off at character 257. The third line I gave was 253 characters long, $_ contained the whole 253 characters. Nothing was chopped off. The fourth line I gave was 839 characters long, $_ contained the last 68 characters. The string was chopped off at character 771. Nikola asked: Exactly how long/big are we talking of making $_? The fourth line is already a very long line. I don't thing it will be more than a 1000 characters per line. The script above is the essence of the problem. I found the problem when I wrote a script that reads in a line at a time from a file. The script was supposed to find a url in each line with an regex, isolate the url and do something with it. The script did not find the url in lines that were longer than 256 characters, because it appeared more in the beginning. I then found out that it was not my regex that was wrong, but $_ did not give me what I wanted. Funny enough, I am able to find the url using index and substring. In this way I was able to do what I wanted to do, but it does not help solving the problem I have. The subroutine that worked was: open DATEI, $_ or die Kann die Datei $_ nicht öffnen ($!)\n; foreach my $line (DATEI) { chomp $line; if ($line =~ /\LI\/i) { my $begin_url = index $line, http; my $end_url = index $line, \ ; my $length = ($end_url - $begin_url) ; my $url = substr ($line, $begin_url, $length); and so on. I would be really grateful for an answer to the puzzle. Kind regards Anette Perl 5.004_04 on my Solaris 5.6 machine had no problems making $_ of length 178956970. Of course I have an elephant crap load of memory on this sucker. Exactly how long/big are we talking of making $_? -Original Message- From: David Gray [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 12, 2002 9:06 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: How long can $_ be? Is there some limit in how long the contents of the variable $_ can be? Not that I'm aware of, no. I encounter this problem on Solaris machines running Perl 5.005. On Windows with Perl 5.6.1. no such problem was encountered. What could
RE: Error installing package
Now I can! Timothy Johnson To: [EMAIL PROTECTED] tjohnson@sand cc: [EMAIL PROTECTED] isk.com Subject: RE: Error installing package 03/07/2002 05:29 PM Are you able to install other packages? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 07, 2002 1:05 PM Cc: [EMAIL PROTECTED] Subject: RE: Error installing package In my case, PPM has been working. PPM QUERY returns a list of the modules that were initially installed. But the error comes each time I try to install new modules with PPM: Installing package 'DBI'... pause Error installing package 'DBI': Could not locate a PPD file for package DBI I assume the problem is related to the corporate firewall, but anyone familiar with this kind of error, I would really appreciate some help. Otherwise management may force me to use Visual Basic! And that is against my religion. thanks, Peter RArul@newenerg yassoc.com To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] 03/07/2002 Subject: RE: Error installing package 03:48 PM Peter, My trick worked. I uninstalled ActivePerl 631 and then again installed it. Now PPM is working like a charm and I was able to install all Modules. I was able to even use query command from ppm which showed all available packages. Thanks, Rex -Original Message- From: Arul, Rex Sent: Thursday, March 07, 2002 3:22 PM To: '[EMAIL PROTECTED]' Cc: '[EMAIL PROTECTED]' Subject: RE: Error installing package I am also having problems with PPM and have posted on Perl-Win-32-Users mailing list at activestate. For me it is Win32-Lanman package. I also having the same problems as you. I did the same thing yesterday and everything worked. It was Activestate Perl Build 631. I had problems with OS (With Windows what else can you expect), and had to reinstall Windows 2000 this morning and then tried installation of ActivePerl 5.6.1 build 631 as I did yesterday. Now PPM has stopped working that I am not able to install even DBI package. When I type ppm query, it is not showing any versions either. Surely something is goofed up big time. I am going to try uninstallation and then installation of ActivePerl once again! -- Rex -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 07, 2002 2:02 PM To: [EMAIL PROTECTED] Subject: Error installing package I am on NT, trying to use 'PPM INSTALL DBI' and receiving an error message: Error installing package 'DBI': Could not locate a PPD file for package DBI: Very frustrating. I have yet to succeed with PPM. I know there is a firewall here, is that possibly the problem? Are there config scripts or file some where? I haven't had much luck locating them. I trust PPM works because I tried 'PPM INSTALL TK' and it returned: Version 800.023 of 'Tk' is already installed. Remove it, or use 'verify --upgrade Tk'. I've been referred to many docs, but none that I've found have been able to help with this. Thanks to any and all who can help me over this hurdle. Peter ** CONFIDENTIALITY NOTICE ** THIS E-MAIL, INCLUDING ANY ATTACHED FILES, MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION FOR THE SOLE USE OF THE INTENDED RECIPIENT(S). ANY REVIEW, USE, DISTRIBUTION, OR DISCLOSURE BY OTHERS IS STRICTLY PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT (OR AUTHORIZED TO RECEIVE INFORMATION FOR THE RECIPIENT), PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DELETE ALL COPIES OF THIS MESSAGE. THANK YOU. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Error installing package
I am on NT, trying to use 'PPM INSTALL DBI' and receiving an error message: Error installing package 'DBI': Could not locate a PPD file for package DBI: Very frustrating. I have yet to succeed with PPM. I know there is a firewall here, is that possibly the problem? Are there config scripts or file some where? I haven't had much luck locating them. I trust PPM works because I tried 'PPM INSTALL TK' and it returned: Version 800.023 of 'Tk' is already installed. Remove it, or use 'verify --upgrade Tk'. I've been referred to many docs, but none that I've found have been able to help with this. Thanks to any and all who can help me over this hurdle. Peter ** CONFIDENTIALITY NOTICE ** THIS E-MAIL, INCLUDING ANY ATTACHED FILES, MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION FOR THE SOLE USE OF THE INTENDED RECIPIENT(S). ANY REVIEW, USE, DISTRIBUTION, OR DISCLOSURE BY OTHERS IS STRICTLY PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT (OR AUTHORIZED TO RECEIVE INFORMATION FOR THE RECIPIENT), PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DELETE ALL COPIES OF THIS MESSAGE. THANK YOU. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Error installing package
In my case, PPM has been working. PPM QUERY returns a list of the modules that were initially installed. But the error comes each time I try to install new modules with PPM: Installing package 'DBI'... pause Error installing package 'DBI': Could not locate a PPD file for package DBI I assume the problem is related to the corporate firewall, but anyone familiar with this kind of error, I would really appreciate some help. Otherwise management may force me to use Visual Basic! And that is against my religion. thanks, Peter RArul@newenerg yassoc.com To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] 03/07/2002 Subject: RE: Error installing package 03:48 PM Peter, My trick worked. I uninstalled ActivePerl 631 and then again installed it. Now PPM is working like a charm and I was able to install all Modules. I was able to even use query command from ppm which showed all available packages. Thanks, Rex -Original Message- From: Arul, Rex Sent: Thursday, March 07, 2002 3:22 PM To: '[EMAIL PROTECTED]' Cc: '[EMAIL PROTECTED]' Subject: RE: Error installing package I am also having problems with PPM and have posted on Perl-Win-32-Users mailing list at activestate. For me it is Win32-Lanman package. I also having the same problems as you. I did the same thing yesterday and everything worked. It was Activestate Perl Build 631. I had problems with OS (With Windows what else can you expect), and had to reinstall Windows 2000 this morning and then tried installation of ActivePerl 5.6.1 build 631 as I did yesterday. Now PPM has stopped working that I am not able to install even DBI package. When I type ppm query, it is not showing any versions either. Surely something is goofed up big time. I am going to try uninstallation and then installation of ActivePerl once again! -- Rex -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 07, 2002 2:02 PM To: [EMAIL PROTECTED] Subject: Error installing package I am on NT, trying to use 'PPM INSTALL DBI' and receiving an error message: Error installing package 'DBI': Could not locate a PPD file for package DBI: Very frustrating. I have yet to succeed with PPM. I know there is a firewall here, is that possibly the problem? Are there config scripts or file some where? I haven't had much luck locating them. I trust PPM works because I tried 'PPM INSTALL TK' and it returned: Version 800.023 of 'Tk' is already installed. Remove it, or use 'verify --upgrade Tk'. I've been referred to many docs, but none that I've found have been able to help with this. Thanks to any and all who can help me over this hurdle. Peter ** CONFIDENTIALITY NOTICE ** THIS E-MAIL, INCLUDING ANY ATTACHED FILES, MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION FOR THE SOLE USE OF THE INTENDED RECIPIENT(S). ANY REVIEW, USE, DISTRIBUTION, OR DISCLOSURE BY OTHERS IS STRICTLY PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT (OR AUTHORIZED TO RECEIVE INFORMATION FOR THE RECIPIENT), PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DELETE ALL COPIES OF THIS MESSAGE. THANK YOU. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Error installing package
Awesome Timothy! You are Awesome! I haven't fixed the Proxy problem, but I copy-pasted the HTTP_PROXY variable name from your email into the search box at ActiveState.com and it gave me a link to a doc that says it can help solve the problem. Unfortunately the network guys went home already. But before the first instruction came this note: NOTE: If none of the changes in this document work for you, you may download individual packages from here [ActivePerl 613 and later] or... so I clicked on it and was able to download zip files that contained the pod files and long story short, I GOT IT! Thank you! Timothy Johnson To: [EMAIL PROTECTED], [EMAIL PROTECTED] tjohnson@sand cc: [EMAIL PROTECTED] isk.com Subject: RE: Error installing package 03/07/2002 04:58 PM Are you using a proxy? If so, check the docs at ActiveState. It's been a long time since I had to do it. I think you have to set up an environment variable (HTTP_PROXY, I think) for PPM to work. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 07, 2002 12:23 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Error installing package I am also having problems with PPM and have posted on Perl-Win-32-Users mailing list at activestate. For me it is Win32-Lanman package. I also having the same problems as you. I did the same thing yesterday and everything worked. It was Activestate Perl Build 631. I had problems with OS (With Windows what else can you expect), and had to reinstall Windows 2000 this morning and then tried installation of ActivePerl 5.6.1 build 631 as I did yesterday. Now PPM has stopped working that I am not able to install even DBI package. When I type ppm query, it is not showing any versions either. Surely something is goofed up big time. I am going to try uninstallation and then installation of ActivePerl once again! -- Rex -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 07, 2002 2:02 PM To: [EMAIL PROTECTED] Subject: Error installing package I am on NT, trying to use 'PPM INSTALL DBI' and receiving an error message: Error installing package 'DBI': Could not locate a PPD file for package DBI: Very frustrating. I have yet to succeed with PPM. I know there is a firewall here, is that possibly the problem? Are there config scripts or file some where? I haven't had much luck locating them. I trust PPM works because I tried 'PPM INSTALL TK' and it returned: Version 800.023 of 'Tk' is already installed. Remove it, or use 'verify --upgrade Tk'. I've been referred to many docs, but none that I've found have been able to help with this. Thanks to any and all who can help me over this hurdle. Peter ** CONFIDENTIALITY NOTICE ** THIS E-MAIL, INCLUDING ANY ATTACHED FILES, MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION FOR THE SOLE USE OF THE INTENDED RECIPIENT(S). ANY REVIEW, USE, DISTRIBUTION, OR DISCLOSURE BY OTHERS IS STRICTLY PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT (OR AUTHORIZED TO RECEIVE INFORMATION FOR THE RECIPIENT), PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DELETE ALL COPIES OF THIS MESSAGE. THANK YOU. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:
'use strict' kills Oracle spooling...
I'll try and keep it short. I have code that opens an Oracle client and pipes it a few SQL statements, including spool. I've heard a lot about 'use strict' and I felt that my code was actually organized well enough to pull this off, so I tried it. The only change I made was to declare all variables 'my'. Now I watch the system call to Oracle and I can see the data scrolling on the command screen (NT), the spool files are created, but they're blank. I tried leaving the 'my' declarations alone, and commented out 'use strict' and it still didn't work. Does anyone familiar with 'use strict' know what may be going on? (Please don't make fun of the way I'm accessing the database. It works, and besides, I've been too lazy to learn about the DBI package/module thing.) ## Original Oracle call (spooling works well): sub callOracle { $SQLline = shift; # Connect to oracle, send SQL statements and close connection to Oracle open (ORACLE, |plus80.exe username/passwd\@DBT) ||# Test #open (ORACLE, |plus80.exe username/passwd\@DBP) ||# Production die Can't open connection to Oracle database: ; print ORACLE $SQLline; close ORACLE; } ## After 'use strict' (no output spooled): sub callOracle { my($SQLline) = shift; # Connect to oracle, send SQL statements and close connection to Oracle open (ORACLE, |plus80.exe username/passwd\@DBT) ||# Test #open (ORACLE, |plus80.exe username/passwd\@DBP) ||# Production die Can't open connection to Oracle database: ; print ORACLE $SQLline; close ORACLE; } ## example of the SQL statement contained in $SQLline (all one string): SET HEAD OFF; SET SERVEROUTPUT OFF; SET PAGESIZE 0; SET ECHO OFF; SET FEEDBACK OFF; SPOOL d:\perldev\lookup\Guard_prov_fac.txt select stuff||','||morestuff from table SELECT '%default%,' FROM DUAL; SPOOL OFF; EXIT; ## ** CONFIDENTIALITY NOTICE ** THIS E-MAIL, INCLUDING ANY ATTACHED FILES, MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION FOR THE SOLE USE OF THE INTENDED RECIPIENT(S). ANY REVIEW, USE, DISTRIBUTION, OR DISCLOSURE BY OTHERS IS STRICTLY PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT (OR AUTHORIZED TO RECEIVE INFORMATION FOR THE RECIPIENT), PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DELETE ALL COPIES OF THIS MESSAGE. THANK YOU.
Re: C++ in perl.
how about system(some command line); ? |+--- || [EMAIL PROTECTED]| || m| || | || 06/08/01 | || 09:45 AM | || | |+--- | || | To: [EMAIL PROTECTED] | | cc: (bcc: Peter Farrar/Waltham/MCS/Concentra)| | Subject: C++ in perl.| | Hey all, I'm rather new to perl, and was just woundering what was the best route to go to Exec c++ from within a perl script. Is there a PM for this? thank in advance.
hiding logins at prompt
Hi, I've got a Perl script that logs into one of our applications as Admin. I didn't want to hard code in the password, so I'm prompting for it. I was looking for a way to hide the input, just like when you log into a Unix or NT box. I was hoping to either have the actual input chars replaced with '*'s or just blanks or something along those lines. Any ideas? -Peter ** CONFIDENTIALITY NOTICE ** THIS E-MAIL, INCLUDING ANY ATTACHED FILES, MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION FOR THE SOLE USE OF THE INTENDED RECIPIENT(S). ANY REVIEW, USE, DISTRIBUTION, OR DISCLOSURE BY OTHERS IS STRICTLY PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT (OR AUTHORIZED TO RECEIVE INFORMATION FOR THE RECIPIENT), PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DELETE ALL COPIES OF THIS MESSAGE. THANK YOU.