http://www.perlmonks.org?node_id=1012817


in reply to Undesirable parent hash keys

You should be testing using exists, because the boolean test you are using will return false if the hash element exists but is undef or zero or the empty string...

That said, I don’t think there is any way to do what you want without the clumsy cascade of tests:

if (exists $Hash{'2013'} && exists $Hash{'2013'}{'Oct'} && ...

because exists also autovivifies intervening elements. According to the documentation:

This surprising autovivification in what does not at first—or even second—glance appear to be an lvalue context may be fixed in a future release.

:-(

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,