http://qs321.pair.com?node_id=748919


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; } }