marcussen has asked for the wisdom of the Perl Monks concerning the following question:
This passed my desk today...
I must admit that I would have expected the result to be the same, yet it appears that the binary and forgets the boundaries of it's condition and always evaluates to true if the left hand condition is true while not encapsulated by parantheses to mark the boundary. Is my interpretation of perldoc perlop wrong or do I need more coolaid?$ perl -e 'my $a=(1 == 1) && (0);print "$a\n";' 0 $ perl -e 'my $a=(1 == 1) and (0);print "$a\n";' 1 $ perl -e 'my $a=((1 == 1) and (0));print "$a\n";' 0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: and vs &&
by kennethk (Abbot) on Feb 12, 2009 at 00:59 UTC | |
|
Re: and vs &&
by JavaFan (Canon) on Feb 12, 2009 at 01:17 UTC | |
|
Re: and vs &&
by ikegami (Patriarch) on Feb 12, 2009 at 03:31 UTC | |
|
Re: and vs &&
by trwww (Priest) on Feb 12, 2009 at 03:53 UTC | |
|
Re: and vs &&
by marcussen (Pilgrim) on Feb 12, 2009 at 01:00 UTC | |
by chromatic (Archbishop) on Feb 12, 2009 at 07:35 UTC | |
by marcussen (Pilgrim) on Feb 13, 2009 at 00:47 UTC | |
|
Re: and vs &&
by imrags (Monk) on Feb 12, 2009 at 08:34 UTC | |
by ikegami (Patriarch) on Feb 12, 2009 at 13:08 UTC |