Types of References I
Learn about the scalar, array, and hash references.
Scalar references
The reference operator is the backslash \
. In scalar context, it creates a single reference that refers to another value. In list context, it creates a list of references. To take a reference to $name
, we can do this:
my $name = 'Larry';
my $name_ref = \$name;
We must dereference a reference to evaluate the value to which it refers. Dereferencing requires us to add an extra sigil for each level of dereferencing:
Get hands-on with 1400+ tech skills courses.