There is an implicit check for definedness when you do while (<FOO>) { }. See the perlop section on I/O Operators.
while (<FOO>) { # do stuff } # terminates if we get a line that evaluates to false. while (my $l = <FOO>) { # do stuff } # only terminates at end of file (or error reading file) while (defined(my $l = <FOO>)) { # do stuff } # Let's take advantage of $_ and be somewhat safe(r). { local $_; while (<FOO>) { # do stuff } }
TGI says moo
In reply to Re^3: Which way is recommended ?
by TGI
in thread Which way is recommended ?
by matrixmadhan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |