in reply to Re^6: why does push not default to $_? (simple)
in thread why does push not default to $_?
Operands are evaluated left-to-right except for assignment operators. Even right-associative ** evaluates its operands left-to-right. It's not documented, but I don't see it changing. From what I've read, I'd even say there's a desire to fix a case where it isn't, should one be found.
If you wanted to avoid relying on the undocumented feature, you'd do
sub push (\@;@) { my $array = shift; CORE::push ( @$array, @_ ? @_ : $_ ) }
Of course, both yours and this modified version fail to handle @b=(); push @a, @b; properly.
|
|---|