I think it's no longer true - and I'm struggling to remember how to test it - but I'm pretty sure there used to be the distinction that while (<>) was special-cased to act as while (defined($_ = <>)), while anything more complicated (such as while ($line = <>)) did not get the "defined" check added to it. So if <> were to return something like an empty string, or "0", the latter case could terminate early.
The oldest perl I have to hand is a maint-5.8, and I couldn't reproduce it there with perl -e 'print "0\n0"' | perl -we 'while ($r = <>) { printf "%s", $r }' -, so either I'm testing it wrong, or it affected only even earlier perls, or I'm going senile. (These options are not necessarily exclusive.)
Update but the point was that it could be written by someone with a vague memory that something like that could happen - much like I have - and if so, that didn't necessarily make it awful code.
|