Re: go to next file

2002-09-12 Thread Michael Fowler
On Thu, Sep 12, 2002 at 05:04:20PM -0700, Harry Putnam wrote: > david <[EMAIL PROTECTED]> writes: > > I must be a real dunce, but I still don't get the point. > If a bad regex is given, I want the program to stop. > > Your script above doesn't spit an error, it just fails and gives some > other

Re: go to next file

2002-09-12 Thread david
Harry Putnam wrote: > david <[EMAIL PROTECTED]> writes: > >> Harry Putnam wrote: >> >>> david <[EMAIL PROTECTED]> writes: >>> >>> Won't is still quite even with the eval, in the above case? passing it to Perl >>> >>> Can you give an example of this? >> >> no it doesn't. if you put it insi

Re: go to next file

2002-09-12 Thread Harry Putnam
david <[EMAIL PROTECTED]> writes: > Harry Putnam wrote: > >> david <[EMAIL PROTECTED]> writes: >> >> Won't is still quite even with the eval, in the above case? >>> passing it to Perl >> >> Can you give an example of this? > > no it doesn't. if you put it inside an eval{}, it won't quit. consid

Re: go to next file

2002-09-12 Thread david
Harry Putnam wrote: > david <[EMAIL PROTECTED]> writes: > > Won't is still quite even with the eval, in the above case? >> passing it to Perl > > Can you give an example of this? no it doesn't. if you put it inside an eval{}, it won't quit. consider: #!/usr/bin/perl -w use strict; my $reg =

Re: go to next file

2002-09-12 Thread Harry Putnam
david <[EMAIL PROTECTED]> writes: > Harry Putnam wrote: > >> >> Excuse my skull bone density... not sure I follow this. Not sure I >> see how `chop' does anything to `\' >> >> [...] >> > > assume your program is named scan.pl, what happen is you call it: > > scan.pl '\' It will wait for inpu

Re: go to next file

2002-09-12 Thread david
Harry Putnam wrote: > > Excuse my skull bone density... not sure I follow this. Not sure I > see how `chop' does anything to `\' > > [...] > assume your program is named scan.pl, what happen is you call it: scan.pl '\' your script always assume user will be entering a valid reg to use. i a

Re: go to next file

2002-09-12 Thread Harry Putnam
david <[EMAIL PROTECTED]> writes: > you are feeding reg directly to Perl from the user in 'if(/$regex/)' there > is a chance that this will crash your program consider: > > #!/usr/bin/perl -w > use strict; > > eval{ > while(){ > chop; > /$_/o; > }

Re: go to next file

2002-09-12 Thread david
Harry Putnam wrote: > #!/usr/local/bin/perl -w > > $regex = shift; > while(<>){ > $cnt++; > if($cnt == 1){ >print "$ARGV\n"; > } > if(/$regex/){ >printf "%-3d %s", $cnt, $_; > }elsif(/^$/){ >$cnt = 0; >next; > } > } you are fe

Re: go to next file

2002-09-12 Thread Harry Putnam
Bob Showalter <[EMAIL PROTECTED]> writes: [...] >> cat test.pl >> #!/usr/local/bin/perl -w >> >> $regex = shift; >> while(<>){ >> $cnt++; >> if($cnt == 1){ >>print "$ARGV\n"; >> } >> if(/$regex/){ >>printf "%-3d %s", $cnt, $_; >> }elsif(/^$/){ >>

Re: go to next file

2002-09-12 Thread Harry Putnam
Dharmender Rai <[EMAIL PROTECTED]> writes: > you are not reading the files properly. > use 2 "while loops". the outer for traversing the > command line args while the inner for reading and > checking the file contents. use "break" in the inner > "while loop" when you get a blank line to go to the

RE: go to next file

2002-09-12 Thread Bob Showalter
> -Original Message- > From: Harry Putnam [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 11, 2002 10:25 PM > To: [EMAIL PROTECTED] > Subject: go to next file > > > I know its possible to force perl to read the next file but have > forgotten how to do it. > > The simple script

Re: go to next file

2002-09-12 Thread Harry Putnam
George Schlossnagle <[EMAIL PROTECTED]> writes: > I think you need to stop programming C. :) > > 'last' is the token you want to use for breaking out of a loop in perl. In the script I posted `last' used in place of next, doesn't work like I wanted. It just stops the script on the first file.

Re: go to next file

2002-09-11 Thread George Schlossnagle
> use "break" in the inner > "while loop" when you get a blank line to go to the > outer "while loop". I think you need to stop programming C. :) 'last' is the token you want to use for breaking out of a loop in perl. George -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comma

Re: go to next file

2002-09-11 Thread Dharmender Rai
you are not reading the files properly. use 2 "while loops". the outer for traversing the command line args while the inner for reading and checking the file contents. use "break" in the inner "while loop" when you get a blank line to go to the outer "while loop". cheers --- Harry Putnam <[EMA