Do you know where your variables are? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
According to perldoc perlop, terms have the highest precedence of everything: A TERM has the highest precedence in Perl. They include variables, quote and quote-like operators, any expression in parentheses ... Please consider the following code.
Given that expressions in parentheses have topmost priority, one would expect Perl to evaluate (banana || cherry) first, which would boil down to say "banana" which would return 1, and only then to evaluate apple && (1). So the output I more or less expected is:
However, the output I get is:
Please shed some light on this. Why isn't the parenthesed expression evaluated first? I understand the short circuiting nature of the logical operators — for one, this explains why cherry isn't outputted at all, but I fail to understand how && seems to have higher precedence than ( EXPR ), despite the information in the documentation. In reply to Operator precedence by muba
|
|