flotsan wrote: > Hey guys, Hello,
> I am reading the Perl Camel book - Programming Perl 3rd Ed and having a bit > of trouble to understand some of the ideas presented in section 2.11.2. > Specifically it is told the following two statements are different: > > 1) if ($_ = <STDIN>) { print; } # suboptimal: doesn't test > defined > 2) if (defined($_ = <STDIN>)) { print; } # best > > But as I see it, these two do the same thing in that in the #1 one, the $_ = > <STDIN> expression returns an lvalue $_ which is then evaluated in the > boolean context provided by the "if" operator. Then it follows if $_ has the > "undef" value, then it would produce a "false" in the boolean context which > is conceptually the same as the 2nd expression. > > Is there anything wrong in my understanding that somebody can straighten me > out? Yes, Perl has five "false" values: undef, (), 0, '' and '0', and two of those are valid input from the readline operator. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>