Why does Autovivification occur with keys() and not %{..}?
问题 This is a subtlety I found with keys() . $ perl -e 'use warnings; use strict; my $d = { "ab" => 1 }; my @e = keys(%{$d->{cd}});' $ perl -e 'use warnings; use strict; my $d = { "ab" => 1 }; my %e = %{$d->{cd}};' Can't use an undefined value as a HASH reference at -e line 1. I am most puzzled as to why the first snippet would not give an dereferencing error. When I use Data::Dumper , it becomes clear that in the first snippet, $d->{cd} , is autovivified to be {} . Why does keys need to