Hmmm...
my %words = (
'lng' => ['lang','long','leng','loo'],
'sentance' => ['sentence'],
'thxs' => ['this','thus']
);
my @results;
for my $key (keys %words) {
if (defined(@results)) {
@results = &loljoin(\@results, $words{$key});
} else {
@results = map {[$_]} @{$words{$key}};
}
}
sub loljoin { #pass me two references to arrays:
my @results = @{(shift)}; #the results so far..
my @newwords = @{(shift)}; #and the set to add to our results
my @newresults;
for my $word (@newwords) {
for my $result (@results) {
push(@newresults,[@$result, $word]);
}
}
return @newresults;
}
# results are in @results as a list of lists
# eg: for my $foo { print join(" ",@$foo) . "\n" }
Hmm, well. That appears to work, but it doesn't look as good as it could.