in reply to looping backwards
The idea is to use a negative slice to remove elements from the end of your list of indices, then unshift them onto the beginning...
I _think_ that's what you want, is it?my @indices=0..$#array; # this is a NOP if $offset is 0, I think my @slice=splice @indices,-$offset; unshift @indices,@slice; foreach my $index(@indices) { # do whatever you want here print $array[$index]; }
|
|---|