Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: chaining de...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 5 Topic 11032 of 11531
Post > Topic >>

Re: chaining defines

by sigzero@[EMAIL PROTECTED] (Robert Hicks) May 6, 2008 at 12:27 PM

Jenda Krynicky wrote:
> From: Robert Hicks <sigzero@[EMAIL PROTECTED]
>
>> Is there anything wrong with:
>>
>> if ( defined $one && defined $two && $one eq $two ) {
>>     #### do something
>> }
> 
> As far as I can tell not. I was afraid the operator precedence might 
> play tricks with it, but looks like it doesn't:
> 
> V:\>perl -MO=Deparse -e "defined $one && defined $two && $one eq 
> $two"
> $one eq $two if defined $one and defined $two;
> -e syntax OK
> 
> V:\>perl -MO=Deparse -e "if(defined $one && defined $two && $one eq 
> $two) {print 'aha'}"
> if (defined $one and defined $two and $one eq $two) {
>     print 'aha';
> }
> -e syntax OK
> 
> I would write it as 
> 
>   if ( defined($one) && defined($two) && $one eq $two ) {
> 
> or even more likely as 
> 
>   if ( defined($one) and defined($two) and $one eq $two ) {
> 
> but it seems your version is just fine.
> 
> Jenda
> 

Thanks very much for the corroboration.

Robert
 




 5 Posts in Topic:
chaining defines
sigzero@[EMAIL PROTECTED]  2008-05-06 09:49:29 
Re: chaining defines
yitzle@[EMAIL PROTECTED]   2008-05-06 10:43:15 
Re: chaining defines
Jenda@[EMAIL PROTECTED]   2008-05-06 18:04:00 
Re: chaining defines
sigzero@[EMAIL PROTECTED]  2008-05-06 12:27:58 
Re: chaining defines
Peter@[EMAIL PROTECTED]   2008-05-07 04:38:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 1:02:10 CDT 2008.