$ perl -e '
use strict;
use warnings;
use Test::More tests => 8;
my $h = { b => {} };
my ($f, $f2, $f3, $f4);
$f = $h->{b}{c}{d} if exists($h->{b}{c}) and exists($h->{b}{c}{d});
is_deeply( $h, { b => {} }, "no autovivification" );
is( $f, undef, "no value assigned" );
$f2 = $h->{b}{c}{d} if exists $h->{b}{c};
is_deeply $h, { b => {} }, "f2: no autovivification";
is $f2, undef, "f2: no value assigned";
$f3 = $h->{b}{c}{d}{x}{y}{z} if
exists $h->{b}{c}
and exists $h->{b}{c}{d}
and exists $h->{b}{c}{d}{x}
and exists $h->{b}{c}{d}{x}{y};
is_deeply $h, { b => {} }, "f3: no autovivification";
is $f3, undef, "f3: no value assigned";
$f4 = $h->{b}{c}{d}{x}{y}{z};
delete $h->{b}{c};
is_deeply $h, { b => {} }, "f4: autovivification removed";
is $f4, undef, "f4: no value assigned";
'
####
$ perl -e '
use strict;
use warnings;
use Test::More tests => 8;
my $h = { b => {} };
my $f = $h->{b}{c}{d} if exists($h->{b}{c}) and exists($h->{b}{c}{d});
is_deeply( $h, { b => {} }, "no autovivification" );
is( $f, undef, "no value assigned" );
my $f2 = $h->{b}{c}{d} if exists $h->{b}{c};
is_deeply $h, { b => {} }, "f2: no autovivification";
is $f2, undef, "f2: no value assigned";
my $f3 = $h->{b}{c}{d}{x}{y}{z} if
exists $h->{b}{c}
and exists $h->{b}{c}{d}
and exists $h->{b}{c}{d}{x}
and exists $h->{b}{c}{d}{x}{y};
is_deeply $h, { b => {} }, "f3: no autovivification";
is $f3, undef, "f3: no value assigned";
my $f4 = $h->{b}{c}{d}{x}{y}{z};
delete $h->{b}{c};
is_deeply $h, { b => {} }, "f4: autovivification removed";
is $f4, undef, "f4: no value assigned";
'
##
##
1..8
ok 1 - no autovivification
ok 2 - no value assigned
ok 3 - f2: no autovivification
ok 4 - f2: no value assigned
ok 5 - f3: no autovivification
ok 6 - f3: no value assigned
ok 7 - f4: autovivification removed
ok 8 - f4: no value assigned