显然我对no autovivification pragma 的理解是不完美的,因为以下脚本的 not-dying-on-line-19 行为让我非常惊讶。
use 5.014;
use strict;
use warnings;
no autovivification qw(fetch exists delete warn);
{
my $foo = undef;
my $thing = $foo->{bar};
# this does not die, as expected
die if defined $foo;
}
{
my $foo = undef;
do_nothing( $foo->{bar} );
# I would expect this to die, but it doesn't
die unless defined $foo;
}
sub do_nothing {
return undef;
}
运行脚本会产生:
Reference was vivified at test.pl line 8.
问题:为什么当作为参数提供给$foo
子时自动激活$foo->{bar}
,即使no autovivification
是有效的?