in reply to Re^3: Hmmm: while(), file handle and $_ gotcha
in thread Hmmm: while(), file handle and $_ gotcha
Using a variable is even required if you want to add error checking.
while (my $line = <DATA>) { if ( $. % 10 == 1 ) { print $line; } for (0 .. 3) { defined( my $important_line = <DATA> ) or die("Premature EOF\n"); print $important_line; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Hmmm: while(), file handle and $_ gotcha
by Porculus (Hermit) on Mar 06, 2009 at 21:47 UTC |
In Section
Seekers of Perl Wisdom