In C we have what we call dangling pointers where if a pointer is pointing to something else and if that something else is deallocated or removed from memory then the pointer that is pointing to that something else is now a dangling pointer. I've been learning the basics of perl but never get to touch pointers. Are there possibilities in PERL to have a dangling pointer? or can we even create pointers in PERL? i'm doing console apps and not for the web.

Recommended Answers

All 2 Replies

In perl you have got reference , it cannot be dangling. The memory management is taken care by the langauge.

Yes, with perl this should not be a problem although it does help to properly declare variables within the intended scope of their use using "my", "our", or "local" when and where appropriate.

As ithelp has said, in perl they are called references. They are mostly used to create complex data strucutes, like a multi-dimensional array or hash, but can be used for other things.

http://perldoc.perl.org/functions/ref.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.