perl reference clarification needed

Viewed 80

Straight from https://perldoc.perl.org/perlref.html

I don't understand below

 $$hashref{"KEY"}   = "VALUE";       # CASE 0
 ${$hashref}{"KEY"} = "VALUE";       # CASE 1
 ${$hashref{"KEY"}} = "VALUE";       # CASE 2
 ${$hashref->{"KEY"}} = "VALUE";     # CASE 3

What is the difference between case 1 and 2?

I am thinking anything inside ${} is a pointer to some address so it's like

my $hashref = \%hash;

${$hashref}{"KEY"} is really $$hashref{"KEY"} and this is dereferencing \%hash and looking up it's "KEY"

${$hashref->{"KEY"}} .. I would think is.. ?? I thought the rule was the bind closest to the left so I thought this also became $$hashref->{"KEY"}. which is same as ${$hashref}{'KEY'}. Am I getting this wrong?

3 Answers
Related