my @results = (""); foreach my $subarray (@array) { my @tmp_results = (); my @subarray = @{ $subarray }; foreach my $tmp_result (@results) { foreach my $element (@subarray) { my $string = $tmp_result . $element; push @tmp_results, $string; } } @results = @tmp_results; } print join "\n", @results; print "\n";