Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Deeper level of hashing

0 views
Skip to first unread message

dn....@gmail.com

unread,
May 2, 2008, 7:15:51 AM5/2/08
to

I am using (roughly) the following code.

my %counter = () ;

$counter{label11}{parent} = 'label1' ;
$counter{label11}{hits} = 14 ;
$counter{label12}{parent} = 'label1' ;
$counter{label12}{hits} = 14 ;

If I use: for my $key(keys %counter), I get label11 and label12 as
values.
I would like to run something like: foreach my $key(keys %
($counter(label11) ) )
and get 'parent' and 'hits' as the sub-keys.

Is there any quick way to do this but quicker than what? So let's say
is there a 'standard way' in which this is done? Or do I have to do it
the 'hard way' ? Define a sub-hash, and then assign it to the parent
hash as its key's value?


Joost Diepenmaat

unread,
May 2, 2008, 7:23:33 AM5/2/08
to
"dn....@gmail.com" <dn....@gmail.com> writes:

Do you mean something like this?

foreach my $key (keys %{$counter{label11}}) {
print "$key => $counter{label11}->{$key}\n";
}


--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

0 new messages