in reply to array push fails
On my (perl 5.24) system, your original code says:map { push( @{$_ % 2 ? \@odd : \@even }, "+$_" ) } @numbers;
Update: BTW - "map" is not the best choice for this code, because you are throwing away the result of the map.Experimental push on scalar is now forbidden at pf.pl line 13, near "" ++$_" ) "
Preferred, and more concise:
Then there is room for optimization:push( @{$_ % 2 ? \@odd : \@even }, "+$_" ) for @numbers;
my @evenodd = (\@even, \@odd); push( @{$evenodd[$_ % 2]}, "+$_" ) for @numbers;
All power corrupts, but we need electricity.
|
|---|