my %log;
defines hash %log
, but lines 12 and 16 don't use it. Instead, you're accessing the anonymous hash referenced by the scalar $log
which you've never declared. You have two options.
You could continue to use an anonymous hash.
my $log = {}; # The creation of the hash ("{}") is currently being done # implicitly by "->". This is called autovivification. ... $log->{...} ...
This adds a bit of a extra complexity and an unnoticeable reduction in speed.
You could use use a hash directly.
my %log; ... $log{...} ...