fatality (after a couple of warnings) for an empty input array
So don't do that :)
Test before entering the loop:
( my $i = $#a ) > 0 or die; $b[ $i ] = $a[ $i ] + $a[ --$i ] while $i;
Never do in a loop, what can be done outside of it.
Wouldn't your version fail for an array with one element?
In reply to Re^3: Abusing Map
by BrowserUk
in thread Abusing Map
by writch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |