[tpm] Stupid question time!
William Witteman
yam at nerd.cx
Fri Jan 29 13:12:40 PST 2010
On Fri, Jan 29, 2010 at 03:55:20PM -0500, Madison Kelly wrote:
>What is the difference between:
>
>if (not $foo && $bar ne "") {}
>if ((not $foo) && ($bar ne "")) {}
>
>I assumed it was mainly an aesthetic/readability thing, but I realize
>that no, it's logically different. Thanks for enlightening me?
I think that it has to do with operator precedence - though I could not
concisely tell you the mechanism of the difference in your example. I
look here:
http://www.perl.com/doc/manual/html/pod/perlop.html
and find that the textual boolean operators are well down the list, so
it would likely evaluate the && first, then the other two left to right
in the first example, whereas in the second the not and the ne would be
evaluated first. That's just a guess though.
--
yours,
William
More information about the toronto-pm
mailing list