are you looking for a subroutine that does rotations?
my @ordered = 1..12; # or 1..11 or 'a'..'zz' etc
my $rot_point = 5; # the index of the value '6'
my @rotated = rotate( $rot_point, @ordered );
If so, maybe the sub below will do what you need...
#!/usr/bin/perl -w
use strict;
my @ordered = 1..12;
for my $rot_num (0..20) {
print( sprintf('%02d ', $_),
"[ ",
join( ', ', &rotate( $rot_num, @ordered ) ),
" ]\n"
);
}
sub rotate {
my $r = shift() % @_; # modulus noop rotations
@_[ $r .. $#_, ( $r ? (0..--$r) : () ) ];
# return end of orig followed by start of orig
}
sub rotate_with_more_input_checking_and_less_fun {
my $r = shift;
return @_ unless ($r>0 and @_);
$r %= @_ if $r >= @_;
return @_ unless $r > 0;
my @a = @_;
push( @a, shift @a) for 1..$r;
return @a;
}