in reply to Re^3: Why are "a ||= b" and "a = a || b" different?
in thread Why are "a ||= b" and "a = a || b" different?

Thanks, diotalevi, your explanation of the side effects makes perfect sense.

Do you have any thoughts about why

($ret1, $ret2) ||= foo();
refreshes $ret2 and not $ret1 with the result of the evaluation of foo() in scalar context as mentioned by varian ?

Update: typo fixed, thx diotalevi.

Replies are listed 'Best First'.
Re^5: Why are "a ||= b" and "a = a || b" different?
by diotalevi (Canon) on Mar 04, 2007 at 22:18 UTC

    You have a typo and meant ||= instead of =||.

    In the case of (A,B) ||= C, (A,B) || ... is the comma operator in scalar context. It evaluates the left argument A, then the right argument B and returns B. Thus you've just written A; B ||= C;.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      D'oh! :). Thanks for clarifying.