The usual way to do a circular array is to use the % operator. For example, this will start from Joe (offset 2):
my @array=qw/ Fred Mark Joe Mary Paul /; my $offset=2; for (0..$#array) { print $array[$offset++ % @array], "\n" }
In reply to Re: looping backwards
by eyepopslikeamosquito
in thread looping backwards
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |