while (<FH>) is "shorthand" for: while (defined( $_=<FH>)), and the defined can sometimes be important if your last entry in a file is a 0 without \n afterwards. And normally, I don't want to miss a single zero at the end which could even happen with <> if you pipe in a file.Good worry, but no need to lose sleep since Perl's behaviour has been adapted to do the right thing in the real world a while ago.
I'm not sure exactly when it changed; perldoc perldelta for 5.6.1 doesn't mention it and I can't seem to find any mention in older versions of the POD found on perldoc.com either. Of course even on older Perls, you can use the my construct by simply adding the defined yourself..$ perl -MO=Deparse -e'1 while my $line = <>;' '???' while defined(my $line = <ARGV>); -e syntax OK $ perl -v This is perl, v5.6.1 built for i386-linux
while(defined(my $line = <>)){ # ... }
Makeshifts last the longest.
In reply to Re^2: Style, style, style
by Aristotle
in thread Style, style, style
by Juerd
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |