J
jkstill
I am trying to do something with hashes that I have not before.
While I am sure it can be done, I can't think of a good way to do it.
Given the following hash:
my %h = (
'first' => {
f0 => 'f_zero',
f1 => 'f_one',
},
'second' => {
s0 => 's_zero',
s1 => 's_one',
}
);
.... print all possible combinations
Easy enough using 2 nested loops.
Four combinations would be printed.
Extend the hash to this:
my %h = (
'first' => {
f0 => 'f_zero',
f1 => 'f_one',
},
'second' => {
s0 => 's_zero',
s1 => 's_one',
}
'third' => {
t0 => 't_zero',
t1 => 't_one',
}
);
This now requires 3 nested loops to get all possible combinations.
The problem is that the number of hashes nested in the %h hash
will not be known until runtime, so hardcoded loops won't work too
well.
Any tips on how to go about this?
TIA
Jared
While I am sure it can be done, I can't think of a good way to do it.
Given the following hash:
my %h = (
'first' => {
f0 => 'f_zero',
f1 => 'f_one',
},
'second' => {
s0 => 's_zero',
s1 => 's_one',
}
);
.... print all possible combinations
Easy enough using 2 nested loops.
Four combinations would be printed.
Extend the hash to this:
my %h = (
'first' => {
f0 => 'f_zero',
f1 => 'f_one',
},
'second' => {
s0 => 's_zero',
s1 => 's_one',
}
'third' => {
t0 => 't_zero',
t1 => 't_one',
}
);
This now requires 3 nested loops to get all possible combinations.
The problem is that the number of hashes nested in the %h hash
will not be known until runtime, so hardcoded loops won't work too
well.
Any tips on how to go about this?
TIA
Jared