Help for this page

Select Code to Download


  1. or download this
    $count = 10;
    
  2. or download this
    $copy = $count;
    
  3. or download this
    $ref = \$count; # initialise $ref's value to be a reference to $count
    
  4. or download this
    print "ref $ref\n";
    
    ref SCALAR(0x000003e8)
    
  5. or download this
    print "ref value $$ref\n";
    
    ref value 10
    
  6. or download this
    @array = (10, 20, 30);
    
  7. or download this
    @copy = @array;
    
  8. or download this
    $ref = \@array;
    
  9. or download this
    print "ref $ref\n";
    
    ref ARRAY(0x000003e8)
    
  10. or download this
    print $ref->[1];
    
    20
    
  11. or download this
    print $$ref[1];
    
    20
    
  12. or download this
    %hash = (a => 1, b => 2);
    
  13. or download this
    $ref = \%hash;
    
  14. or download this
    print "ref $ref";
    
    ...
    print $$ref{b};
    
    2
    
  15. or download this
    $array[1] = @another; # nope - number of entries in @another is assign
    +ed to $array[1]
    
  16. or download this
    $array[1] = \@another;
    
    print $array[1]->[0]; # the first entry in the referenced array
    
  17. or download this
    
    sub func {
    ...
    }
    
    func(@ten_million);
    
  18. or download this
    sub func {
       my ($aref) =@_;
    ...
    }
    
    func(\@ten_million);
    
  19. or download this
    $ref = \@array;
    
    ...
    print "ref $ref\n";
    
    1001