![]() |
|
Keep It Simple, Stupid | |
PerlMonks |
Re^2: Pointers and Referencesby Leudwinus (Scribe) |
on Nov 25, 2020 at 17:36 UTC ( #11124209=note: print w/replies, xml ) | Need Help?? |
Hi Ken, You're using terms — pointer, address, memory location — which I suspect you've picked up from one or more other languages. You are then attempting to apply those terms to Perl, assuming they have the same meaning. I think this may be the source of your problems. Guilty as charged! I was trying to replicate in Perl the following program from a C tutorial on functions and pointers:
Perhaps I just need to focus on one language at a time! And thank you for the detailed example and explanation! You can reference and dereference to great depths if you want; as in this exaggerated example I'm just reading this now but came to the same conclusion earlier today when I was reading some of the other responses to this thread. I suggest you play around with examples like these to get a better understanding of how all of this works. Agreed. What I take away from your examples is that when I try to print or output a variable that contains a reference, I can clearly see what that is in reference to. For example:
This helps you understand how to dereference it:
I hope I got that last bit right! Also note that I didn't use, or indeed need, terms such as pointer, address or memory location. Duly noted! And thanks for the alias tip. I will have to park that one away for the time being because as useful as Perl one-liners are, I don't think I'm quite ready to use them that frequently. Gratias tibi ago
In Section
Seekers of Perl Wisdom
|
|