develooper Front page | perl.beginners | Postings from May 2008

Re: chaining defines

Thread Previous | Thread Next
From:
Peter Scott
Date:
May 7, 2008 04:43
Subject:
Re: chaining defines
On Tue, 06 May 2008 18:04:00 +0200, Jenda Krynicky wrote:
> From: Robert Hicks <sigzero@gmail.com>
>> 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

A bit more explicitly (and interestingly different):

$ perl -MO=Deparse,-p -e 'defined $one && defined $two && $one eq $two'
((defined($one) and defined($two)) and ($one eq $two));
-e syntax OK

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/


Thread Previous | Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About