introduction to Perl 5 for web developers Creating References 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/bin/perl -wT
     use strict;
     my $name      = "Selena Sol";
     my $reference = \$name;

Notice the backslash character before $name.

Creating array, hash and subroutine references follows the exact same process such as:

     my $array_reference = \@array_name;
     my $hash_reference  = \%hash_name;
     my $subroutine_ref  = \&sub_name;
Previous | Next | Table of Contents