quick question.
Say I have a hash of hashes, like this for example:
$DB{$membername}{'IP'} = $ipaddress;
$DB{$membername}{'ID'} = $membrID;
$DB{$membername}{'GRP'} = $membrgroup;
My question is simply out of my own curiosity, and doesn't really have any use that I can think of, but let's say we go
foreach $val (sort values %DB){
print "$val\n";
}
that should print the value for each of the first hash right? When I run it it prints things like:
HASH(0x80fa52c)
HASH(0x80fa568)
HASH(0x80fa5a4)
Which makes sense, because the value of each hash IS a hash right? Well, how could it to print the values using (sort values %DB) ?
I've tried going:
foreach %val (sort values %DB){
foreach $key (sort keys %val){
print "- $key";
}
print "\n";
}
But that doesn't work either. If it can be done how would I do it?
(and yes, I realize that using (keys %DB) would work easily)
thanks
Say I have a hash of hashes, like this for example:
$DB{$membername}{'IP'} = $ipaddress;
$DB{$membername}{'ID'} = $membrID;
$DB{$membername}{'GRP'} = $membrgroup;
My question is simply out of my own curiosity, and doesn't really have any use that I can think of, but let's say we go
foreach $val (sort values %DB){
print "$val\n";
}
that should print the value for each of the first hash right? When I run it it prints things like:
HASH(0x80fa52c)
HASH(0x80fa568)
HASH(0x80fa5a4)
Which makes sense, because the value of each hash IS a hash right? Well, how could it to print the values using (sort values %DB) ?
I've tried going:
foreach %val (sort values %DB){
foreach $key (sort keys %val){
print "- $key";
}
print "\n";
}
But that doesn't work either. If it can be done how would I do it?
(and yes, I realize that using (keys %DB) would work easily)
thanks