Perl 5 Dereferencing Operators : Reference « Data Type « Perl






Perl 5 Dereferencing Operators

   

Type            Operator                  Example
Scalar          $$reference               $ref = $name; print "$$ref";
Array           @$reference               $arrayRef = \@array; print "@$arrayRef";
Array scalar    $$reference[index]        $ref = \@digits; $nine = $$ref[9];
Array index     $#$reference              $ref = \@digits; $lastIndex = $#$ref;
Hash            %$reference               $ref = %inventory; ($item, $cost) = each %$ref;
Hash scalar     $$reference               $ref = %inventory; $itemCost = $$ref{'BrandX 16oz};

   
    
    
  








Related examples in the same category

1.Perl 5 Reference Assignments
2.Reference is a scalar variable
3.Increments Reference
4.Nested reference
5.References to references
6.References, Pointers
7.Creating and Dereferencing Pointers
8.Creating and dereferencing a reference
9.Creating reference for arrays
10.Demonstrates the reference syntax
11.Dereference pointer
12.Dereferencing a Reference
13.Dereferencing the Pointer
14.Direct Reference Techniques
15.Direct Scalar References
16.Exchange reference
17.Get a reference to a file handle by using '$ioreference = *name{IO};'
18.Get reference of a range
19.Get the reference of the return value from substr
20.Get the reference to a scalar by using the form '$scalarreference = *name{SCALAR};'
21.Get the reference to a subroutine by using the form '$codereference = *name{CODE};'
22.Get the value from a reference
23.A reference is a scalar variable pointing-or refering to-something else
24.Reference Modification
25.Using $$ to get the value of the reference