use strict; use warnings; my @lists = ( [1, 2], ['a', 'b'], ['#', '*', '&'], ); # we know the total number of results will be: my $num_results = 1; $num_results *= $_ for map {scalar @{$_}} @lists; my $max_i = $num_results - 1; # build the result list entries left to right my @res = map { '' } 0 .. $max_i; my $pivot = $num_results; for my $list (@lists) { my $j = -1; my $len = scalar @{$list}; $pivot = $pivot / $len; for my $i (0 .. $max_i) { $j++ if $i % $pivot == 0; $j = 0 if $j == $len; $res[$i] .= $list->[$j]; } } print join( "\n", @res), "\n";