>type llarochelle.pm use strict; use warnings; use Test::More tests=>1; my $VAR1 = { '4' => [ '4', '8', '12' ], '1' => [ '1', '5', '9' ], '3' => [ '3', '7', '11' ], '2' => [ '2', '6', '10' ] }; my @array = qw(1 2 3 4 5 6 7 8 9 10 11 12); my $counter = 1; my $data; for my $pos (0 .. $#array) { $data->{ $pos%4 + 1 }[ int($pos / 4)] = $array[$pos]; } is_deeply($data, $VAR1); >perl llarochelle.pm 1..1 ok 1