http://www.perlmonks.org?node_id=132467


in reply to Re: Re: When does while() test for defined vs truth
in thread When does while() test for defined vs truth

When Perl sees you using <FH> or $var = <FH> in a while (or until), it will insert the defined() for you. From perlop in bleadperl:
The following lines are equivalent:
while (defined($_ = <STDIN>)) { print; } while ($_ = <STDIN>) { print; } while (<STDIN>) { print; }
(...)

In these loop constructs, the assigned value (whether assignment is automatic or explicit) is then tested to see whether it is defined. The defined test avoids problems where line has a string value that would be treated as false by Perl, for example a "" or a "0" with no trailing newline.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;