in reply to Why Perl boolean expression sometimes treated as lvalue?
Quite simply:
- $y always returns the scalar, not a copy of it.
- && always returns the scalar its LHS returned or the scalar(s) its RHS returned, not a copy of it.
That's it. Why isn't it documented that they don't make a copy in rvalue context? Why would it.
If you wanted to explicitly copy the scalar, you could do a( 0+( $x && $y ) ). Then, $_[0] = 3; will modify the anonymous scalar the addition constructed.
In Section
Seekers of Perl Wisdom