It's not because of an optimization.
# $_ $_[0] $_[1] $_[0] $_[1] # ----- ----- ----- ----- ----- $_ = 1; # 1 do { # local @_; # alias $_[0] = $_+=2; # 3 $_ 3 alias $_[1] = $_+=3; # 6 $_ $_ 6 6 &f; };
Add $_++; to f and you'll see it print 7, 7 because $_[0] and $_[1] are aliased to $_.
It works that way because += returns its LHS as an lvalue.
>perl -le "$_=1; ($_+=2)+=3; print $_" 6
In reply to Re^5: Puzzling $| behavior
by ikegami
in thread Puzzling $| behavior
by saintmike
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |