假设我有一个 Perl 脚本:
my $hash = {};
$hash->{'a'} = {aa => 'b'};
$hash->{'b'} = undef;
for (qw(a b c)) {
    if(defined $hash->{$_}->{aa})
    {
        say "defined $_";
    }
    else
    {
        say "undef $_";
    }
}
print Dumper $hash;
但是我的输出会自动创建“c”,这是我不想要的。
defined a
undef b
undef c
$VAR1 = {
      'c' => {},
      'a' => {
               'aa' => 'b'
             },
      'b' => {}
    };
此外,我的发行版不允许我禁用自动生存。有没有办法制作一个检查每个级别的子程序?