my $f; $f = $h->{b}{c}{d} if exists($h->{b}{c}) and exists($h->{b}{c}{d}); #### use feature 'state'; # 'use 5.10' or later also gives this automatically state $f = $h->{b}{c}{d} if exists($h->{b}{c}) and exists($h->{b}{c}{d});