Hello!
Hello,
I am thinking about making clear and short script to rotate array, let's say:
input: @list = (1 .. 20); $start = 10; #starting position $values = 10; #how much values in result
how to get output: @result = ( 5, 6, 7, 8, 9, 11, 12, 13, 14, 15 ); #10 values (I don't want $start in @result)
ofcoure script should work with overlapping too: @list = (1 .. 20); $start = 18; $items = 10;
output: @result = ( 13, 14, 15, 16, 17, 19, 20, 1, 2, 3 ); #10 values
any ideas ?
my @result = @list[ map { $_ < @list ? $_ : $_ - $#list - 1 } $start .. $start + $items - 1 ];
John -- use Perl; program fulfillment
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>