use Data::Dumper qw(Dumper); my $a = { b => {} }; my $f = $a->{b}{c}{d}//undef; print Dumper $a #### $VAR1 = { 'b' => { 'c' => {} } };