Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

The Concept of References

by leriksen (Curate)
on Apr 14, 2005 at 06:19 UTC ( #447659=perlmeditation: print w/replies, xml ) Need Help??

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
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://447659]
Approved by BrowserUk
Front-paged by ghenry
help
Chatterbox?
[Lady_Aleena]: This evening, I thought to myself, "I would love to search Netflix for 100 randomfilms from my database to see if they have them." So I went to CPAN to see if there were a modiule which could do such a thing. There is, but GUH! ...
[Lady_Aleena]: ... Does it have to be that hard and complex to use to do a search on Netflix?
Lady_Aleena grumbles.
[Lady_Aleena]: I really need to get back into the swing of Perl. I'm forgetting things from lack of use. I don't know how behind I am too.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2017-01-21 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (180 votes). Check out past polls.