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

I thought of ... but I don't think that would work ...

But what happened when you tried it?

>perl -wMstrict -le "my $hash = { 'A' => { 'B5' => { 'C' => 123, 'D' => 103, }, 'B2' => { 'C' => 101, }, }, }; ;; if (exists $hash->{'A'}{'B2'}) { for my $k (keys %{ $hash->{'A'}{'B2'} }) { print qq{'$k' -> $hash->{'A'}{'B2'}{$k}}; } } " 'C' -> 101
  • Comment on Re: Hash of hash: testing for existence of higher level key (only)
  • Download Code

Replies are listed 'Best First'.
Re^2: Hash of hash: testing for existence of higher level key (only)
by zuma53 (Beadle) on Jun 22, 2012 at 05:23 UTC
    I tried that, but it never got to the loop. I double-checked and there was a hash key/value there.

    I will revisit this once again.

    Thanks for the help!