Upon reflection -- and I'm surprised Randal hasn't picked this up -- the
"problem" might be more deep-seated than we imagine. With respect to the
good Perl-Meisters who've answered so far, I should like to add this:

        Shouldn't it be "Flotsam", and not "flotsan"? <g>

(Hey! After all, somebody's got to add a human dimension to this fun techie
stuff. Sorry, I just couldn't resist.)

John --

Vice President / Chief Technical Officer
Small Business Help Center, Inc.




-----Original Message-----
From: flotsan [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 22, 2006 1:39 AM
To: beginners@perl.org
Subject: Question on the "Camel" book

Hey guys,

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?

flotsan 



--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/>
<http://learn.perl.org/first-response>






-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.0.394 / Virus Database: 267.0.0/449 - Release Date: 9/15/2006


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to