February 2012
Intermediate to advanced
1184 pages
37h 17m
English
You can create a reference to any named variable or subroutine with a backslash. (You may also use it on
an anonymous scalar value like 7
or "camel", although you won’t
often need to.) This operator works like the & (address-of) operator in C—at least
at first glance.
Here are some examples:
$scalarref = \$foo; $constref = \186_282.42; $arrayref = \@ARGV; $hashref = \%ENV; $coderef = \&handler; $globref = \*STDOUT;
The backslash operator can do more than produce a single reference. It will generate a whole list of references if applied to a list. See the upcoming sectionOther Tricks You Can Do with Hard References for details.
Read now
Unlock full access