perl -MData::Dumper -e 'my %h; print "yes\n" if exists $h{d}{j}; print Dumper \%h;' $VAR1 = { 'd' => {} }; #### if(defined $h{d} && exists $h{d}{j}) {...} #### my %hash; $hash{d}{j} = 'foo'; #### my %hash; $hash{d} ||= {}; $hash{d}{j} = 'foo';