http://qs1969.pair.com?node_id=11105921


in reply to Round robin processing

very nice solutions, All!

Me? late to the party as usual, but my contribution:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @array = qw(1 2 3 4 5 6 7 8 9 10 11 12); my $size = @array; my $count = int($size / 4); my $counter = 1; my $result = {}; for (0..2) { push @{$result->{$counter++}}, @array[0 ..$count-1]; @array = @array[$count .. $#array]; } push @{$result->{$counter}}, @array[0 ..$#array] if @array; print Dumper($result); __output__ $VAR1 = { '1' => [ '1', '2', '3' ], '3' => [ '7', '8', '9' ], '4' => [ '10', '11', '12' ], '2' => [ '4', '5', '6' ] };