EXPR1 ||= EXPR2 is sort of a super charged
EXPR1 = EXPR1 || EXPR2. However, if
EXPR1
is an array (say
@a), it would expand to:
@a = @a || EXPR2. Nothing wrong with the latter,
but the two
@a's are quite different. The one on
the left hand side is an lvalue in list context, the one
on right hand side of the assignment is in scalar context.
However,
EXPR1 ||= EXPR2 isn't syntactic
sugar for
EXPR1 = EXPR1 || EXPR2, because in the
latter,
EXPR1 is executed twice, in the former, just
once. But if
EXPR1 in
EXPR1 ||= EXPR2 is
only going to be executed once, what should it be? The scalar value, or the list value? Both are needed.
Abigail