I don't know that these have catchy names.
In
perlref this is referred to as dereferencing a BLOCK that returns a reference. But I don't think I've ever heard anyone refer to these as such. From
perlref:
2. Anywhere you'd put an identifier (or chain of identifiers) as part
+ of a
variable or subroutine name, you can replace the identifier with a
+BLOCK
returning a reference of the correct type. In other words, the pre
+vious
examples could be written like this:
$bar = ${$scalarref};
push(@{$arrayref}, $filename);
${$arrayref}[0] = "January";
${$hashref}{"KEY"} = "VALUE";
&{$coderef}(1,2,3);
$globref->print("output\n"); # iff IO::Handle is loaded
Admittedly, it's a little silly to use the curlies in this case, bu
+t the
BLOCK can contain any arbitrary expression, in particular, subscrip
+ted
expressions:
&{ $dispatch{$index} }(1,2,3); # call correct routine
Because of being able to omit the curlies for the simple case of "$
+$x",
people often make the mistake of viewing the dereferencing symbols
+as
proper operators, and wonder about their precedence. If they were,
though, you could use parentheses instead of braces. That's not th
+e
case. Consider the difference below; case 0 is a short-hand versio
+n of
case 1, not case 2:
$$hashref{"KEY"} = "VALUE"; # CASE 0
${$hashref}{"KEY"} = "VALUE"; # CASE 1
${$hashref{"KEY"}} = "VALUE"; # CASE 2
${$hashref->{"KEY"}} = "VALUE"; # CASE 3
Case 2 is also deceptive in that you're accessing a variable called
%hashref, not dereferencing through $hashref to the hash it's presu
+mably
referencing. That would be case 3.