Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: difference between pointer and referrence in perl

by biohisham (Priest)
on Aug 26, 2009 at 21:44 UTC ( #791467=note: print w/replies, xml ) Need Help??


in reply to difference between pointer and referrence in perl

In addition to arrays, hashes, and scalar references you also have:
  1. subroutine references.
  2. typeglob references.
  3. references to lists (distinct from references to arrays).
  4. IO references.
  5. LVALUE references.

one distinguishing feature of Perl, not available in C involves DYNAMIC creation of data structures and prevents excessive typing, this feature is called Autovivification, in reference view, a reference springs to existence if it is dereferenced under the assumption that it exists. With this in mind, you would notice that Perl references and C pointers are not exactly the same.

EXAMPLE: (Note the reference is held in the scalar value $reference!) $$reference=5; #Dereferencing before creating a reference. print "$$reference\n"; #Creation of $reference autovivifically. print "$reference\n";

Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://791467]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2021-06-19 07:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (91 votes). Check out past polls.

    Notices?