Argel has asked for the wisdom of the Perl Monks concerning the following question:
and:local $/; # Added in an update while( <IN> ) { while( /$regex/gm ) { ... } }
Is there any significant advantage to using the top method over the bottom one? Or is the only benefit just being able to use $_ implicitly? Just curious if there was more to the story.local $/; # Added in an update my $file = <IN>; while( $file=~/$regex/gm ) { ... }
UPDATE: Sorry, forget to mention that I did local/undef $/ so I could slurp the file into one big string (have 8000+ substitutions to make and plenty of memory -- file is about 1.3MB, system has 12GB). That would make the two roughly equivalent, right?
Elda Taluta; Sarks Sark; Ark Arks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Advantage of while(<>){while()}?
by davido (Cardinal) on May 18, 2011 at 21:21 UTC | |
|
Re: Advantage of while(<>){while()}?
by ikegami (Patriarch) on May 18, 2011 at 21:37 UTC | |
by Argel (Prior) on May 18, 2011 at 21:56 UTC | |
|
Re: Advantage of while(<>){while()}?
by ikegami (Patriarch) on May 18, 2011 at 22:14 UTC | |
by Argel (Prior) on May 18, 2011 at 22:21 UTC | |
by ikegami (Patriarch) on May 18, 2011 at 22:24 UTC | |
by Argel (Prior) on May 18, 2011 at 22:32 UTC | |
|
Re: Advantage of while(<>){while()}?
by JavaFan (Canon) on May 18, 2011 at 21:33 UTC |