http://qs1969.pair.com?node_id=11114300


in reply to Precedence for Idiots

The penultimate row of the table in the "Logical Questions" section seems incorrect to me.

$ perl -E '$x = 1 == 2 && 3; say $x;' $

This is what I would expect since 1 == 2 is clearly false so $x is false and the right hand side of the && is never evaluated. Perhaps you meant this instead:

$ perl -E '$x = 2 == 2 && 3; say $x;' 3 $

Now the first term is clearly true and the second term evaluates to 3 as intended.

Replies are listed 'Best First'.
Re^2: Precedence for Idiots
by soonix (Canon) on Mar 15, 2020 at 17:29 UTC
    More probably Melly just confounded the last two results…
Re^2: Precedence for Idiots
by rsFalse (Chaplain) on Mar 05, 2021 at 11:39 UTC
    For me "Logical Questions" section's table seems much confusing!
    Column "Meaning" doesn't really mean what is written in column "Function".
    E.g. look at the first example line. Operator 'or' has even higher precedence than '=' and meaning becomes not '($x = (5 == 6)) or ($x = (5 == 5))' but '($x = (5 == 6)) or (5 == 5)', i.e. right side of 'or' operator are not ever assigned to '$x';