Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Hash of hash: testing for existence of higher level key (only)

by NetWallah (Abbot)
on Jun 22, 2012 at 06:13 UTC ( #977780=note: print w/ replies, xml ) Need Help??


in reply to Hash of hash: testing for existence of higher level key (only)

If you know what the third level's key should be, you can check for existence:

if (exists $hash->{A}->{B2}->{C}) { ...
If you do not know, you will need to iterate:
for my $k (keys %{ $hash->{A}->{B2} } ){ ...
Why don't you TRY the code you think should work (or fail), and if it behaves differently from your expectations, we can help explain why.

As for the thing you were attempting in your previous node:

$hash->{'A'}->{'B2'}->{*} #is actually Equivalent to my @subkeys = keys %{ $hash->{A}->{B2} }; #at least - I think this is where you were heading...

             I hope life isn't a big joke, because I don't get it.
                   -SNL


Comment on Re: Hash of hash: testing for existence of higher level key (only)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://977780]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2014-12-25 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls