What I need is to loop through unknown number of arrays of unknown length. Assume I have this data
my @aAry = qw ( a b c );
my @bAry = qw ( d );
my @cAry = qw ( e f g h );
There may be more. what I would do for a know quantity is :
for (my $i = 0; $i < scalar(@aAry); $i++) {
for (my $j = 0; $j < scalar(@bAry); $j++) {
for (my $k = 0; $k < scalar(@cAry); $k++) {
$str = $aAry[$i].'.'.$bAry[$j].'.'.$cAry[$k];
print "${str}\n";
}
}
}
The results would be every possible combination, 3 wide, of every item in each list.
a.d.e , a.d.f, a.d.g, a.d.h, b.d.e, b.d.f, b.d.g, b.d.h, c.d.e, c.d.f, c.d.g, c.d.h
3 wide(3 arrays) * 4(widest array) = 12 combinations There may be from 2 to 10 arrays that may be a width from 1 to 200 wide and I need to generate all possible combinations across N arrays that are M wide I'm thinking that I may be able to put them all into a single multi-dimensional array and just skip
my @mdARY = ( qw (a b c)
, qw ( d )
, qw ( e )
);
for ($i = 0; $i < scalar(@mdARY); $i++) {
for ($j = 0; $j < scalar(@{$mdARY[$i]}); $j++) {
But this ain't gonna work either. Maybe recursion???