# loop over all but last element foreach my $i ( 0 .. $#array-1 )