$ perl -MData::Dumper -e 'my $h; $h->{x}++ if exists $h->{x}; print Dumper($h)' $VAR1 = {}; $ perl -MData::Dumper -e 'my $h; $h->{x}++ if defined $h->{x}; print Dumper($h)' $VAR1 = {}; #### if ($h and exists $h->{x}) #### if ($h and exists $h->{a} and exists $h->{a}{b} and exists $h->{a}{b}{foo})