zuma53 has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to query the hash, but all I am given for inputs for queries are just values for the first two keys. Some examples: A/B5, A/B9, C/B2. If there's a hit (eg A/B5), then I could ask for the keys and iterate through that subhash.$hash->{'A'}->{'B5'}->{'C'} = 123; $hash->{'A'}->{'B5'}->{'D'} = 103; $hash->{'A'}->{'B2'}->{'C'} = 101;
but I don't think that would work, as Perl would think that's another hash enitrely.if (exists $hash->{'A'}->{'B2'}) ...
Is there a way to do this without iterating through the levels of the HoH?$hash->{'A'}->{'B2'}->{*}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash of hash: testing for existence of higher level key (only)
by AnomalousMonk (Archbishop) on Jun 22, 2012 at 05:19 UTC | |
by zuma53 (Beadle) on Jun 22, 2012 at 05:23 UTC | |
|
Re: Hash of hash: testing for existence of higher level key (diver)
by tye (Sage) on Jun 22, 2012 at 04:23 UTC | |
|
Re: Hash of hash: testing for existence of higher level key (only)
by NetWallah (Canon) on Jun 22, 2012 at 06:13 UTC | |
|
Re: Hash of hash: testing for existence of higher level key (only)
by frozenwithjoy (Priest) on Jun 22, 2012 at 05:40 UTC | |
|
Re: Hash of hash: testing for existence of higher level key (only)
by AnomalousMonk (Archbishop) on Jun 22, 2012 at 20:03 UTC |