Creating References
September 28, 1998
There are several ways to create a reference
depending on what type of object you want to reference.
The most basic method for creating a reference
is to use the backslash (\) operator. For example, to create a simple
scalar reference, you would use something like the following:
#!/usr/local/bin/perl
$name = "Selena Sol";
$reference = \$name;
Notice the backslash character before $name.
Creating array, hash and subroutine references
follows the exact same process such as:
$array_reference = \@array_name;
$hash_reference = \%hash_name;
$subroutine_ref = \&sub_name;
References
Introduction to Perl 5 | Table of Contents
Dereferencing a Reference
|