Philip Potter <philip.g.pot...@gmail.com> asked:
> Won't this loop terminate early if there is a blank line or a line
> containing only '0'? If I do a readline loop I always do:
> while (defined ($line = <$file>))
> 
> Is there something magical happening here I don't know about? I know
> about the magical:
> 
> while (<$file>)
> 
> which is equivalent to:
> 
> while (defined($_ = <$file>))
> 
> but I don't know of any magic in the while loop at the top.

See the Camel book, p.81:

"[...]

   while( my $line = <STDIN> ) { print $line; } # now private

Both of these while loops still implicitly test for whether the result of the 
assignment is defined, [...]"

HTH,
Thomas

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to