use strict; use warnings; my %h; unless (exists($h{foo}{bar})) { print "\$h{foo}{bar} exists: no\n"; print "\$h{foo} exists: ", exists($h{foo})?'yes':'no', "\n"; } #outputs # $h{foo}{bar} exists: no # $h{foo} exists: yes