R
Ravi Parimi
Hi ,
I have 4 hashes %aries, %taurus, %gemini, %leo, and each hash has
key=>value pairs like:
$aries{"beta"} = "192.168.2.10"
$aries{"gamma"} = "192.168.2.11"
and so on.
I would like to be able to print the contents of each hash without
explicity looping over the name of each hash.. I did something like:
foreach $foo qw /aries taurus gemini leo/ {
foreach $var (keys %foo) {
print "$var => $foo{$var}\n";
}
}
I know it doesnt make sense to do it this way, but is there a way such
that $foo in the first loop above can become a hash on each iteration
so that the inner loop works without any problem?
Thanks,
--ravi
I have 4 hashes %aries, %taurus, %gemini, %leo, and each hash has
key=>value pairs like:
$aries{"beta"} = "192.168.2.10"
$aries{"gamma"} = "192.168.2.11"
and so on.
I would like to be able to print the contents of each hash without
explicity looping over the name of each hash.. I did something like:
foreach $foo qw /aries taurus gemini leo/ {
foreach $var (keys %foo) {
print "$var => $foo{$var}\n";
}
}
I know it doesnt make sense to do it this way, but is there a way such
that $foo in the first loop above can become a hash on each iteration
so that the inner loop works without any problem?
Thanks,
--ravi