note
Dominus
Says [MeowChow]:
<blockquote><i>
It looks as if any complex sub-expressions /subroutine calls are evaluated in order, and
variables/references are evaluated last.
</i></blockquote>
That's very astute of you. It's not exactly what's going on, but it's very close.
For simple variables, Perl pushes what is
effectively a reference onto the stack.
But for complex ecpressions, Perl must construct the
new value and push a reference to that instead. So if
<tt>$i = 2</tt>, then <tt>$i</tt> in the list pushes a
reference to <tt>$i</tt> itself, but <tt>$i + 0</tt> copies <tt>$i</tt>
and pushes a reference to the copy of the 2. If you later change
<tt>$i</tt>, the first 2 changes but the second one doesn't.<p>
Your original example works the same way.<p>
This could be considered a bug. It has come up on p5p before,
but I don't remember what the outcome of the discussion was.<p>
Contrary to what [id://66885|chromatic said], it is <i>not</i> a precedence issue.
Precedence only affects parsing, not execution.
66880
66897