use strict; use warnings; use Data::Dumper; my %hash; my $tmp; print "key foo->bar exists\n" if $tmp = $hash{foo} and exists $tmp->{bar}; print Dumper(\%hash);