# note that we want $i to stop one short of $#array, # since we access $array[$i+1]. for ( my $i = 0; $i < $#array; ++$i ) { push @result, compute( $array[$i+1], $array[$i] ); }