References and Data Structures

Creating a reference to a named variable

To create a reference to a named variable we use a backslash.


Let's say we have the following variables in our program, describing the human PLD 1 protein:

$protein_name = 'PLD1';

@synonyms     = ('Phospholipase D1',
                 'Phosphatidylcholine-hydrolyzing phospholipase D1',
                 'Choline phosphatase 1',
%information  =
   ('Catalytic activity'   => 'PC + H(2)O = Choline + PA',
    'Function'             => 'Signal transduction, membrane trafficking',
    'Regulation'           => 'Activated by PIP2, PIP3, ARF1',
    'Subcellular location' => 'Cytoplasmic, and inner membrane-associated',
    'Similarity'           => 'Belongs to the Phospholipase D family');
We can create a reference to each of these variables:
$ref_to_name        = \$protein_name;
$ref_to_synonyms    = \@synonyms;
$ref_to_information = \%information;

Other references

It is also possible to create references to subroutines and to filehandles. For example:
\&store_info; #ref to the code inside the subroutine 'store_info'
               (assuming we defined that subroutine earlier in the program.)

\*PROTEIN;    #ref to the PROTEIN filehandle.
               (assuming we opened that filehandle earlier in the program.)

Table of Contents.
Previous | Next.