fcntl with F_GETLK returns lock holders pid as 0 with perl 5.6.1

2002-04-11 Thread Sudarsan Raghavan
Hi All, The following code gives the pid of the process holding the lock as 0 when run with perl 5.6.1 on Redhat linux 7.2. It works fine with perl 5.6.0 on the same machine. The code that locks the file works fine (tested by getting the lock information with C code and using 5.6.0 perl). Has any

problem with oracle sequences

2002-04-11 Thread stephen . redding
Hi all, this is a difficult one to explain!! i have a perl script that is inserting entries into an oracle database table. so far so good!! the difficulty i have is that the table has a sequence against a unique id column (number) that can increment itself using seq.nextval. when i test the scri

Problem with replacing text in a variable...

2002-04-11 Thread Wim
Hello people from the mighty list, I have a problem with substitutions... In the piece of code, here below, "display $var1, $var"' should be "display val1, val2"; I don't see why, but the if condition doesn't seems to work... and if I remove the if condition, the replacement doesn't occur... Does

Re: problem with oracle sequences

2002-04-11 Thread Jenda Krynicky
From: [EMAIL PROTECTED] > Hi all, this is a difficult one to explain!! > > i have a perl script that is inserting entries into an oracle database > table. so far so good!! the difficulty i have is that the table has a > sequence against a unique id column (number) that can increment itself > usi

problem with directory listing

2002-04-11 Thread richard noel fell
Below is sample code that does not work as I intend, the intention being to list all the sub-directories in a given directory. #!/usr/local/ActivePerl-5.6/bin/perl5.6.1 -w use strict; my $mw; my $menubar; my $algebra; my @file_array; my $dir_to_process = "/home/rfell/mathprogram"; opendir DH, $

RE: problem with directory listing

2002-04-11 Thread John Edwards
Whitespace, whitespace, whitespace. Right, got that over with now let's look at your code (formatted so it's readable) #!/usr/local/ActivePerl-5.6/bin/perl5.6.1 -w use strict; my $mw; my $menubar; my $algebra; my @file_array; my $dir_to_process = "/home/rfell/mathprogram"; opendir DH, $dir_to_

Re: Problem with replacing text in a variable...

2002-04-11 Thread p
Wim, You're not declaring $var1 or $var2 anywhere. Instead you're assigning 'val1' and 'val2' to elements in the hash %VarValue. So something like... $VarValue{$var1} = 'val1'; print "I like $VarValue{$var1}!"; will print out... I like val1 To define $var1, do something like: $var1 = 'cheese'

RE: problem with directory listing

2002-04-11 Thread John Edwards
Sorry. That should have been prepend. -Original Message- From: John Edwards [mailto:[EMAIL PROTECTED]] Sent: 11 April 2002 12:47 To: 'richard noel fell'; [EMAIL PROTECTED] Subject: RE: problem with directory listing Whitespace, whitespace, whitespace. Right, got that over with now let'

Re: Problem with replacing text in a variable...

2002-04-11 Thread Wim
Tristan, I'm writing a script to send command from a textfile to cisco devices... I the textfile, I like to have variables, something like conf t int $interface . when my script reads the line, it should replace $interface by the value asked from the value the user enters... $var{$interfa

Re: [htmltmpl] form and frames - HELP !!!

2002-04-11 Thread William R Ward
"Aman Raheja" <[EMAIL PROTECTED]> writes: > Hi everyone > I have a situation here. I have to do it this way, becuase that's how the > framework is. > When I submit a form, it is processed by abc.cgi. > Now this abc.cgi has to be a frame. The main page is xyz.cgi, with a header, > a left frame an

Re: problem sending mail

2002-04-11 Thread Skymarket Postmaster
> Hi all > I am trying to send a mail with the following code and the last print > statement doesn't print, ie, the mail is not sent. > This code is called on submitting a form on the web > > open(MAIL, "/usr/sbin/sendmail -oi -t") || die "Can't open mail"; > print MAIL < To:

Re: problem with directory listing

2002-04-11 Thread richard noel fell
John - Thank you for your explanation. A stupid mistake on my part. Dick Fell John Edwards wrote: > > Sorry. That should have been prepend. > > -Original Message- > From: John Edwards [mailto:[EMAIL PROTECTED]] > Sent: 11 April 2002 12:47 > To: 'richard noel fell'; [EMAIL PRO

Re: Re: Problem with replacing text in a variable...

2002-04-11 Thread p
Wim, I can't believe how long it's taken me to figure out what you're on about, and what the problem (probably) is. My brain's far too slow to be at work today :) If cmd came from standard input or something, your script would work. But you're using a string to simulate that input, and because

Re: Re: Problem with replacing text in a variable...

2002-04-11 Thread p
Wim, Sorry, I forgot to mention escaping/single quoting the hash keys too... As you defined it, your hash is empty as you are trying to set 'val1', 'val2' to VarValue{undef} ($Var1 hasn't been defined). Try VarValue{'$Var1'} or VarValue{"\$Var1"} Now the string '$Val1' is a the key, not undef.

Net::SMTP Question

2002-04-11 Thread David Simcik
I've been experiencing a weird behavior lately with one of my messaging scripts. I keep on seeing msg recipients getting BCC'd a copy of the msg, in addition to their listing in the To: field. I have no idea why, but it seems to have something to do with the "hard" ->recipient method call - but wh

Deleting the contents of a file

2002-04-11 Thread Allison Ogle
Hi, I want to opena datafile and erase it's all it's contents. Can anyone help? Thanks, Allison -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Deleting the contents of a file

2002-04-11 Thread RArul
perldoc -f unlink -Original Message- From: Allison Ogle [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 11, 2002 10:26 AM To: [EMAIL PROTECTED] Subject: Deleting the contents of a file Hi, I want to opena datafile and erase it's all it's contents. Can anyone help? Thanks, Allison

help installing HTML::Template;

2002-04-11 Thread A Taylor
Hi all, I am trying to write a perl script that uses different HTML templates depending on the data drawn from a DataBase. It seems the only solution is to use the PERL module HTML::Template; but my web host doesn't support this and wont install it. Is there anyway I can install it myself ?

RE: Deleting the contents of a file

2002-04-11 Thread Nikola Janceski
I think... open(DATA, ">$file") or die "cannot open: $!"; would do the trick. > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 11, 2002 10:25 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: Deleting the contents of a file >

re: previous question about multiline comments

2002-04-11 Thread Teresa Raymond
From: Builder http://builder.com.com Presents your PERL E-NEWSLETTER for April 11, 2002 COMMENT OUT CODE WITH POD Commenting out large blocks of code can be more laborious in Perl than in C and C++ because Perl doesn't have a multiline comment operator like '/* .. */'. A decent editor with mac

RE: Deleting the contents of a file

2002-04-11 Thread Kipp, James
cat /dev/null >datafile > -Original Message- > From: Nikola Janceski [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 11, 2002 10:33 AM > To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: Deleting the contents of a file > > > I think... > > open(DATA, ">$f

RE: Deleting the contents of a file

2002-04-11 Thread A Taylor
Hi, I am very new to PERL but if all you want to do is open an existing file and delete all of it's contents you could open the file for writing and then close it. open(F, ">filename"); close (F); There maybe a more acceptable way to do this - but this should open the file - remove its conten

news groups and GD

2002-04-11 Thread James Campbell
Hi Dudes Two questions for ya. What clients can I use to you connect to comp.lang.perl.modules? I've tired a browser and telnet. had a look in my e-mail client options. No joy. The second question is... Why wont *any* of the versions of GD.pm install on my RedHat Linux box (kernal 7.2)? I'm

Re: Deleting the contents of a file

2002-04-11 Thread Jeff 'japhy' Pinyan
On Apr 11, Allison Ogle said: >I want to opena datafile and erase it's all it's contents. Can anyone help? No need to open the file. truncate($path_to_file, 0); -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.or

Extracting values from hash keys

2002-04-11 Thread Dave Chappell
Hi, I have a hash that will have some keys contain single values and other keys that will have multiple values: %hash = ( key1 => 'test-1', key2 => ['test-2-0', 'test-2-1'], key3 => 'test-3' ); I want to loop t

RE: Extracting values from hash keys

2002-04-11 Thread Nikola Janceski
Use the ref function.. foreach $key(keys %hash) { if(ref($hash{$key})){ print "$key = array( "; foreach my $item (@{$hash{$key}}){ print "$item "; ) print ")\n";

Re: internal structure

2002-04-11 Thread Jonathan E. Paton
> How about the JIT engine then. JIT runs on bytecode, producing bytecode. > When does parrot use it? Before executing bytecode. > how well does it scale? ( has anyone done some benchmarking ) Don't ask me :P If you haven't already, then you'd be best looking at the background information at

Re: internal structure - erroneous post, please ignore

2002-04-11 Thread Jonathan E. Paton
[ Send to wrong mailinglist - meant for perl6-internals] > > How about the JIT engine then. > > JIT runs on bytecode, producing bytecode. > > > When does parrot use it? > > Before executing bytecode. > > > how well does it scale? ( has anyone done some benchmarking ) > > Don't ask me :P If

Matching last comma (not last character)

2002-04-11 Thread p
Hi, I've got a comma separate list, like: apples, oranges, pears I'd like to make it reads: apples, oranges, or pears My guess was to use s/// to turn the last ',' into ', or' Any ideas? Thanks Tristan ___ sent via the murky.net webmai

Use of uninitialized value in concatenation (.)

2002-04-11 Thread Scott Taylor
When I put the -w switch on I get this error: Use of uninitialized value in concatenation (.) at /var/www/cgi-bin/ticket.cgi line 71: on this line: print "$trd Driver ID:$columns[19] -- $drvname"; Can anyone point out my mistake? It still runs but fills up my error_log and I do have the variabl

Re: help installing HTML::Template;

2002-04-11 Thread amfax
http://stason.org/TULARC/webmaster/myfaq.html#7 has a guide to this. I'm using HTML::Template (installed into my own directory) and I like it, but TMTOWTDI. I understand Mason is pretty cool, but I've never done it. And of course, there's PHP... --Jerry http://www.jerrymccusker.com/ At 02

RE: Use of uninitialized value in concatenation (.)

2002-04-11 Thread Nikola Janceski
One of the vars in the print are empty or equal to "". to ignore this for just that line use this unless all the vars are supposed to have something in them. { no warnings 'uninitialized'; print "$trd Driver ID:$columns[19] -- $drvname"; } > -Original Message- > From: Scott Taylor [mail

Re: Matching last comma (not last character)

2002-04-11 Thread Jeff 'japhy' Pinyan
[What mail client are you using? It refuses to include a Date: header] On , [EMAIL PROTECTED] said: >apples, oranges, pears > >I'd like to make it reads: > >apples, oranges, or pears No need to use a regex, especially since a regex will have to go through the whole string. # if there is a c

RE: Matching last comma (not last character)

2002-04-11 Thread Nikola Janceski
here is your substitution.. (haven't tested it but should work). s/,([^,]*)$/, or$1/; > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: None > To: [EMAIL PROTECTED] > Subject: Matching last comma (not last character) > > > Hi, > > I've got a comma sepa

RE: problem with directory listing

2002-04-11 Thread Jason Larson
> -Original Message- > From: richard noel fell [mailto:[EMAIL PROTECTED]] > Subject: problem with directory listing > > Below is sample code that does not work as I intend, the > intention being > to list all the sub-directories in a given directory. > > #!/usr/local/ActivePerl-5.6/bin/

Regexp tester

2002-04-11 Thread Babichev Dmitry
Hello, beginners. Sorry to trouble you. Is anybody use any free Regexp tester? Like in the OptiPerl - but it's non-free... :( Thank you in advance. Babichev L. Dmitry -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: use of package in a script

2002-04-11 Thread drieux
On Wednesday, April 10, 2002, at 09:20 , Jenda Krynicky wrote: No flame war intended... [..] > Anyway ... to sum this all up I'd say: > > 1) If you are not sure you know whadaheck package means ... >don't use it in your code. > 2) If you introduce another package in a script

Re: Re: Matching last comma (not last character)

2002-04-11 Thread p
Thanks, it works great. I used the regex in the end, the list will only ever be a few elements long (and the script doesn't need to be efficient). Can't say I understand it completely though (I was with you up until the first comma) :) Apologies for my mail client. It's a web-based dohickey th

Re: Ip address

2002-04-11 Thread drieux
On Wednesday, April 10, 2002, at 06:58 , Jorge Goncalvez wrote: > Hi, I tried to get the IP address in a Win98 machine I made a perl module > and I > put it in /site/lib with .pm extension. > it is Registry98.pm > > But I have this error: > Can't call method Open of a undefined value at Registr

RE: Deleting the contents of a file

2002-04-11 Thread Hooten, Michael
unlink will delete the file. The filename will no longer exist in a directory listing also. open FILE ">file.txt"; # You can then print to file.txt if you wish. # If you do not write to the file, its size will be ZERO system ("echo >file.txt") # works also but size of the file is 1 byte -Or

RE: Regexp tester

2002-04-11 Thread Wagner-David
If on windows environment, you can try Komodo ( ActiveState IDE ) which has a Regex tester. Wags ;) -Original Message- From: Babichev Dmitry [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 11, 2002 08:28 To: [EMAIL PROTECTED] Subject: Regexp tester Hello, beginners. Sorry to

Re: Use of uninitialized value in concatenation (.)

2002-04-11 Thread p
Scott, You've declared it... my $drvname; ...but not initialised it(given it a value). So at the moment it has the special value 'undef' (which is treated as 0 in a numeric context, or '' in a scalar one). Try and do much with an undef and you'll get a warning, basically reminding you to do so

RE: Use of uninitialized value in concatenation (.)

2002-04-11 Thread Nikola Janceski
Whoa! thanks for the clarification. I need to take out some of my no warnings now. ;) > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: None > To: [EMAIL PROTECTED] > Subject: Re: Use of uninitialized value in concatenation (.) > > > Scott, > > You've de

Re: Use of uninitialized value in concatenation (.)

2002-04-11 Thread Scott Taylor
At 09:01 AM 11/04/2002, [EMAIL PROTECTED] wrote: >Scott, > >You've declared it... >my $drvname; >...but not initialised it(given it a value). So at the moment it has the >special value 'undef' (which is treated as 0 in a numeric context, or '' >in a scalar one). Try and do much with an undef and

Re: Regexp tester

2002-04-11 Thread Babichev Dmitry
Hello, Wagner-David. You wrote 11 àïðåëÿ 2002 ã., 19:00:01: fanx WDvc> If on windows environment, you can try Komodo ( ActiveState IDE ) which has a Regex tester. WDvc> Wags ;) WDvc> -Original Message- WDvc> From: Babichev Dmitry [mailto:[EMAIL PROTECTED]] WDvc> Sent: Thursda

RE:regex tester

2002-04-11 Thread James Campbell
Hi >Is anybody use any free Regexp tester? >Like in the OptiPerl - but it's non-free... :( Don't know how complicated OptiPerl is but if you just want to see what your regex is matching: ~~~ #!/usr/bin/perl while (<>) { chomp; if (/YOUR_PATTERN_GOES_HERE/) {

RE: Problem with replacing text in a variable...

2002-04-11 Thread David Gray
> I have a problem with substitutions... > In the piece of code, here below, > "display $var1, $var"' should be "display val1, val2"; > I don't see why, but the if condition doesn't seems to > work... and if I remove the if condition, the replacement > doesn't occur... Does any of you know why?

Re: Use of uninitialized value in concatenation (.)

2002-04-11 Thread drieux
On Thursday, April 11, 2002, at 08:17 , Scott Taylor wrote: [..] > on this line: > print "$trd Driver ID:$columns[19] -- $drvname"; > > Can anyone point out my mistake? > It still runs but fills up my error_log > and I do have the variables initialized before the loop: > my $trd = ""; > my $drvna

Re: Re: Matching last comma (not last character)

2002-04-11 Thread Jeff 'japhy' Pinyan
On , [EMAIL PROTECTED] said: >I used the regex in the end, the list will only ever be a few elements >long (and the script doesn't need to be efficient). Can't say I >understand it completely though (I was with you up until the first >comma) :) Ok, here's an explanation: >> s/,(?=[^,]*$)/, or/

RegEx matching multiple items.

2002-04-11 Thread Kingsbury, Michael
Given text such as : - -> "SPRID12345678" "SPRID23456789" - I want to match the SPRID strings. I was trying to get them to be in $1 $2 etc, as there's almost always 1, sometimes more, sometimes none, but almost never more than 3-4. How would I match them. To t

RE: Re: Matching last comma (not last character)

2002-04-11 Thread Nikola Janceski
yeah... Japhy almost always beats me in the sensible algorithms.. his rindex idea is the most efficient way, then his regex with the positive look ahead assertion, then my crappy poorly thoughtout regex. ;) > -Original Message- > From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] > Sent

Re: RegEx matching multiple items.

2002-04-11 Thread Jeff 'japhy' Pinyan
On Apr 11, Kingsbury, Michael said: > > > -> "SPRID12345678" >"SPRID23456789" > > >I want to match the SPRID strings. @data = $string =~ /SPRID\d+/g; Or, if you only want the numbers: @data = $string =~ /SPRID(\d+)/g; This is assume $string is the ENTIRE data. Otherwis

Re: Problem with replacing text in a variable...

2002-04-11 Thread wim
An update on previous post... It seems that I typed some errors :-( This is a small rewrite of my script... #!/usr/bin/perl use warnings; my $var = "test"; my $rvar = "\$interface"; my $cmd = "int \$interface\n"; print "$var\n"; print "$cmd\n"; $cmd =~ s/$rvar/$var/g; print "$cmd\n"; If y

RE: RegEx matching multiple items.

2002-04-11 Thread Amerson, Kevin
Hello, How would you put the matches into a comma separated list? -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 11, 2002 12:48 PM To: Kingsbury, Michael Cc: '[EMAIL PROTECTED]' Subject: Re: RegEx matching multiple items. On Apr 11, Kings

Re: Problem with replacing text in a variable...

2002-04-11 Thread bob ackerman
On Thursday, April 11, 2002, at 10:57 AM, wim wrote: > my $var = "test"; > my $rvar = "\$interface"; > try: my $rvar = '\$interface'; so it doesn't look like a variable to be interpolated when you get to the substitution. > my $cmd = "int \$interface\n"; > > print "$var\n"; > print "$cmd\

RE: Problem with replacing text in a variable...

2002-04-11 Thread David Gray
> An update on previous post... > It seems that I typed some errors :-( > > This is a small rewrite of my script... > #!/usr/bin/perl > > use warnings; > > my $var = "test"; > my $rvar = "\$interface"; > my $cmd = "int \$interface\n"; > > print "$var\n"; > print "$cmd\n"; > > $cmd =~ s/$rva

Re: RegEx matching multiple items.

2002-04-11 Thread bob ackerman
On Thursday, April 11, 2002, at 11:46 AM, Amerson, Kevin wrote: > Hello, > > How would you put the matches into a comma separated list? > if you want to print it out: print "@data"; if you want to create a single string: $data = join ',',@data; or did you have something else in mind? > > --

while and do

2002-04-11 Thread Teresa Raymond
Could someone explain the while and do w/ couple of examples? I have yet to use them, only using the foreach loop and if else stmts. -- --- - Teresa Raymond - - Mariposa Net - - http://www.mariposanet.com - ---

RE: RegEx matching multiple items.

2002-04-11 Thread Amerson, Kevin
Nope that was it, I just knew that we didn't have to loop through the array to build the string :) Thanks! -Original Message- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 11, 2002 1:57 PM To: [EMAIL PROTECTED] Subject: Re: RegEx matching multiple items. On Thurs

RE: while and do

2002-04-11 Thread Nikola Janceski
while ($file = shift @build_line or $dir = shift @makedir){ # will do @build_line first then @makedir } # can't do that with foreach do{ # do this loop at least once regardless of the conditional at the end print "This time ", $n++," attempts.\n"; } until ($n >= 1);

Re: while and do

2002-04-11 Thread drieux
On Thursday, April 11, 2002, at 12:02 , Teresa Raymond wrote: > Could someone explain the while and do w/ couple of examples? I have yet > to use them, only using the foreach loop and if else stmts. the obvious ones are while() { # bunch of stuff one wants to do with

while and do

2002-04-11 Thread Bryan R Harris
Some useful perl control structures: do { statements; } while someexpression; do { statements; } until someexpression; while (someexpression) { statements; } --or-- statement while someexpression; until (someexpression) { statements; } --or-- statement until someexpression; unless (someexpressio

Re: Extracting values from hash keys

2002-04-11 Thread John W. Krahn
Dave Chappell wrote: > > Hi, Hello, > I have a hash that will have some keys contain single values and other keys > that will have multiple values: > > %hash = ( > key1 => 'test-1', > key2 => ['test-2-0', 'test-2-1'], > key3 => 'test-3' > ); The simple answer is to put all values

Re: while and do

2002-04-11 Thread John W. Krahn
Teresa Raymond wrote: > > Could someone explain the while and do w/ couple of examples? I have > yet to use them, only using the foreach loop and if else stmts. Have you read the perlsyn document? John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additi

Capturing/controlling signals...

2002-04-11 Thread Nikola Janceski
I have a script that waits for user input, and prints info based on the info. The print info part sometimes takes a long time. I want to capture the INT signal (^C) but depending on if I am waiting for input or printing something I want (^C) to act differently. This program loops endlessly, waiti

Security question re POST data

2002-04-11 Thread Shaun Fryer
Please take into account that I'm new at this... Rather than using CGI.pm, I'm using the following library sub-routine which was passed to me by a friend (I think from one of the O'Reilly books). What I'm wondering is if Perl 5 has any built in functionality to prevent buffer overruns or excessiv

RE: while and do

2002-04-11 Thread Timothy Johnson
Just for those who haven't figured out why the first example is so useful, consider what perl is doing in the following two snippets: 1 == open(INFILE,"myfile.txt"); @file = ; foreach(@file){ do something to $_... } 2 == open(INFILE,"myfile.txt"); while(){ do something to $_... }

max/min

2002-04-11 Thread Bryan R Harris
$someVar = max(@listofvalues); Is there a function in perl like this? - B -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Security question re POST data

2002-04-11 Thread Jeff 'japhy' Pinyan
On Apr 5, Shaun Fryer said: >Rather than using CGI.pm, I'm using the following library sub-routine >which was passed to me by a friend (I think from one of the O'Reilly >books). What I'm wondering is if Perl 5 has any built in functionality I highly doubt it was found in an O'Reilly book -- if i

Re: max/min

2002-04-11 Thread Jeff 'japhy' Pinyan
On Apr 11, Bryan R Harris said: >$someVar = max(@listofvalues); > >Is there a function in perl like this? You could use the List::Util module (from CPAN). Or, you could write your own: sub max { my $max = shift; for (@_) { $max = $_ if $_ > $max } return $max; } -- Jeff "japh

Re: Security question re POST data

2002-04-11 Thread Jenda Krynicky
From: Shaun Fryer <[EMAIL PROTECTED]> > Please take into account that I'm new at this... > > Rather than using CGI.pm, I'm using the following library sub-routine > which was passed to me by a friend (I think from one of the O'Reilly > books). Especialy since you are new at this you should use

Re: Capturing/controlling signals...

2002-04-11 Thread Jonathan E. Paton
> I have a script that waits for user input, and prints info based on the > info. The print info part sometimes takes a long time. > > I want to capture the INT signal (^C) but depending on if I am waiting for > input or printing something I want (^C) to act differently. > This program loops endl

Re: while and do

2002-04-11 Thread bob ackerman
On Thursday, April 11, 2002, at 01:17 PM, Timothy Johnson wrote: > > Just for those who haven't figured out why the first example is so useful, > consider what perl is doing in the following two snippets: > > 1 > == > open(INFILE,"myfile.txt"); > @file = ; > foreach(@file){ >do somethin

RE: while and do

2002-04-11 Thread Timothy Johnson
Good catch. That's what I meant, alright. -Original Message- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 11, 2002 2:34 PM To: Timothy Johnson Cc: [EMAIL PROTECTED] Subject: Re: while and do On Thursday, April 11, 2002, at 01:17 PM, Timothy Johnson wrote:

Re: max/min

2002-04-11 Thread bob ackerman
On Thursday, April 11, 2002, at 01:42 PM, Jeff 'japhy' Pinyan wrote: > On Apr 11, Bryan R Harris said: > >> $someVar = max(@listofvalues); >> >> Is there a function in perl like this? > > You could use the List::Util module (from CPAN). Or, you could write your > own: > > sub max { > my

RE: max/min

2002-04-11 Thread Nikola Janceski
ACK! void use of map! change it! change it! $max=0; foreach (@listofvalues) {$max=$_ if($_>$max)} > -Original Message- > From: bob ackerman [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 11, 2002 5:52 PM > To: [EMAIL PROTECTED] > Subject: Re: max/min > > > > i like: > $max=0; > ma

Re: while and do

2002-04-11 Thread Bryan R Harris
even better... __ On Thursday, April 11, 2002, at 01:17 PM, Timothy Johnson wrote: > > Just for those who haven't figured out why the first example is so useful, > consider what perl is doing in the following two snippets: > > 1 > == > open(INFILE,"myfile.txt"); > @file =

Re: max/min

2002-04-11 Thread bob ackerman
On Thursday, April 11, 2002, at 02:56 PM, Nikola Janceski wrote: > ACK! void use of map! > > change it! change it! > $max=0; > fussy correction for case where all values are negative: $max=$listofvalues[0]; (assumes list isn't empty). > foreach (@listofvalues) {$max=$_ if($_>$max)} > >> ---

Re: max/min

2002-04-11 Thread Bryan R Harris
After I sent this I had a flash of enlightenment: $max = (sort {$a <=> $b} @_)[-1]; May be slower, though, I don't know. - B On Apr 11, Bryan R Harris said: >$someVar = max(@listofvalues); > >Is there a function in perl like this? You could use the List::Util module (from CPAN). Or, yo

RE: max/min

2002-04-11 Thread Bryan R Harris
> ACK! void use of map! > > change it! change it! > $max=0; > foreach (@listofvalues) {$max=$_ if($_>$max)} Huh? Is that "void" or "avoid"? What's wrong with map? - B __ > -Original Message- > From: bob ackerman [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 11,

Re: max/min

2002-04-11 Thread Jonathan E. Paton
> After I sent this I had a flash of enlightenment: > >$max = (sort {$a <=> $b} @_)[-1]; > > May be slower, though, I don't know. How many times have I seen this? I mean, I've seen this construct many times, and the question deserves a place in the Perl FAQ. Please refer back to: http://

Re: RE:regex tester

2002-04-11 Thread Kris G Findlay
- Original Message - From: "James Campbell" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, April 11, 2002 5:31 PM Subject: RE:regex tester > Hi > > >Is anybody use any free Regexp tester? > >Like in the OptiPerl - but it's non-free... :( > > Don't know how complicated O

Re: regular expression to get a file extension

2002-04-11 Thread Jeff 'japhy' Pinyan
On Apr 11, Ahmed Moustafa said: >> # foo.txt.bak => bak >> ($extension) = $name =~ /.*\.([^.]*)/; >> # or >> # ($extension) = $name =~ /\.([^.]*)$/; > >It doesn't work if there is no extension in $name. Yes, and like I said in the post, if there is NO extension AT ALL (meaning no . at al

Re: regular expression to get a file extension

2002-04-11 Thread Ahmed Moustafa
> # foo.txt.bak => bak > ($extension) = $name =~ /.*\.([^.]*)/; > # or > # ($extension) = $name =~ /\.([^.]*)$/; It doesn't work if there is no extension in $name. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Fidning the index of an array

2002-04-11 Thread James Taylor
How can I get the current index of an array while processing the array in a loop? I know I can do it with a counter type function, but I was curious if there was a better way of doing this. For example: my @array = (1 .. 100); my $counter = 0; for (@array) { print "index -> $counter elem

Re: Fidning the index of an array

2002-04-11 Thread Jeff 'japhy' Pinyan
On Apr 11, James Taylor said: >How can I get the current index of an array while processing the array >in a loop? I know I can do it with a counter type function, but I was >curious if there was a better way of doing this. That won't be automatic until Perl 6. Your method is fine. >my @array