How can I check if a key exists in a deep Perl hash?

Viewed 13725

If I understand correctly, calling if (exists $ref->{A}->{B}->{$key}) { ... } will spring into existence $ref->{A} and $ref->{A}->{B} even if they did not exist prior to the if!

This seems highly unwanted. So how should I check if a "deep" hash key exists?

5 Answers
Related