http://www.perlmonks.org?node_id=1018092


in reply to Why Perl boolean expression sometimes treated as lvalue?

Quite simply:

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.

Replies are listed 'Best First'.
Re^2: Why Perl boolean expression sometimes treated as lvalue?
by Anonymous Monk on Feb 11, 2013 at 04:58 UTC
    You're missing the point

      If so, your message does not help. Please clarify the question if you think I didn't understand it.

        If so, your message does not help. Please clarify the question if you think I didn't understand it.

        Consider that you didn't miss the point -- in what way does your reply constitute an answer or an explanation?

        foo( $blah && $foo ); works to alias $foo

        $ref = \($blah && $foo); works to reference $foo

        ( $blah && $foo ) = foo(); is illegal

        Where is this documented? Why is it illegal?

        Oh, ikegami says it doesn't return a copy (why would it) -- who asked about a copy ?