in reply to Re^2: Hmmm: while(), file handle and $_ gotcha
in thread Hmmm: while(), file handle and $_ gotcha
Hold up. How does one variable - two, if you did what I do and use a variable for the outer read as well - equate to clutter? I'd probably remove the unused $cnt if I was going to knock clutter out.
use Modern::Perl; while (my $line = <DATA>) { if ( $. % 10 == 1 ) { print $line; } for (0 .. 3) { my $important_line = <DATA>; print $important_line; } }
I realize this is a matter of personal aesthetics, of course. I was just a little confused how declaring and using a variable (and avoiding weird behavior from <DATA>) was better than declaring an unused variable and getting the weird behavior.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Hmmm: while(), file handle and $_ gotcha
by ikegami (Patriarch) on Mar 06, 2009 at 17:48 UTC | |
by Porculus (Hermit) on Mar 06, 2009 at 21:47 UTC |
In Section
Seekers of Perl Wisdom