$#b = $#a-1; # Allocate a big enough array $i = @b; $b[ $i ] = $a[ $i ] - $a[ $i+1 ] while $i--;