in reply to Re: (another) HoH question
in thread (another) HoH question

Almost there.

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?

Thanks!

Replies are listed 'Best First'.
Re^3: (another) HoH question
by AnomalousMonk (Archbishop) on Jun 23, 2012 at 18:30 UTC
    ... 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