Using Object Methods
If a reference happens to be a reference to an object, then the class that defines that object probably provides methods to access the innards of the object, and you should generally stick to those methods if you’re merely using the class (as opposed to implementing it). In other words, be nice and don’t treat an object like a regular reference, even though Perl lets you when you really need to. Perl does not enforce encapsulation. We are not totalitarians here. We do expect some basic civility, however.
In return for this civility, you get complete orthogonality between objects and data structures. Any data structure can behave as an object when you want it to―or not, when you don’t.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access