I added 'my %hash', and it cleared up the error in the assignments. But it still complains about '$hash->{$key}'. I thought this was covered in 'my %hash' as isn't $hash-{$key} pointing to %hash? What am I missing?
... isn't $hash-{$key} pointing to %hash? What am I missing?
You're missing the point that the expressions $hash{foo} and $hash->{foo} refer to different and quite separate hashes.
>perl -wMstrict -le
"my %hash = ( foo => 'bar' );
my $hash = { foo => 'not_bar_at_all' };
;;
print qq{what is foo? $hash{foo}};
print qq{what is foo? $hash->{foo}};
"
what is foo? bar
what is foo? not_bar_at_all