Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: difference between pointer and referrence in perl

by JavaFan (Canon)
on Aug 26, 2009 at 21:13 UTC ( #791461=note: print w/replies, xml ) Need Help??


in reply to difference between pointer and referrence in perl

They are not the same. Sure, they both "point" to something, but that's about it. In C, a pointer is just an integer - you can add to it: you can say, don't give me the thing it's pointing at, give me whatever is 5 places further. Regardless whether 5 places further actually has stored something that's meaningful.

You can't do that in Perl. You cannot stuff an integer in a reference and have Perl retrieve what's in that memory address. And while you can add something to a reference, the result is a number - not a reference. You cannot dereference the result of the addition.

IMO, saying that "Perl references" and "C pointer" are kind of the same is only useful if you know enough Perl and C to know the differences.

  • Comment on Re: difference between pointer and referrence in perl

Replies are listed 'Best First'.
Re^2: difference between pointer and referrence in perl
by Anonymous Monk on Mar 30, 2014 at 07:41 UTC
    Thanks for explaining clearly with example

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2021-06-14 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (64 votes). Check out past polls.

    Notices?