Using foreach loops only:
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";
The trick is in the overwritting of @results with @tmp_results at the end of the outer loop, as well as in initializing @results with a single empty list in order for concatenation to work further down.
This could probably be written with several map's, but it might become difficult to read.