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

The equivalent would actually be

$ret ||= (foo())[-1];

Replies are listed 'Best First'.
Re^3: Why are "a ||= b" and "a = a || b" different?
by ambrus (Abbot) on Mar 05, 2007 at 10:15 UTC

    I'm affraid no.

    sub foo { wantarray or die "this function is called in list context in all ex +amples"; "alpha", "beta", "gamma"; } $ret = undef; ($ret) = $ret || foo(); print "parenthetical: $ret\n"; $ret = undef; $ret ||= (foo())[0]; print "zero: $ret\n"; $ret = undef; $ret = (foo())[-1]; print "minus one: $ret\n";
    Gives
    parenthetical: alpha zero: alpha minus one: gamma
      My apologies. My test was wrong.