Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: characterstics of private in perl

by graff (Chancellor)
on Mar 09, 2003 at 04:07 UTC ( [id://241494]=note: print w/replies, xml ) Need Help??


in reply to characterstics of private in perl

While this is not something I've had much (any) personal practice with, I recall from reading about it, in Damian's excellent book (Object Oriented Perl, esp. chapter 11), that you can effectively "hide" object data by using closures; e.g.:
{ my $object_data; sub _get_data { return $object_data; } }
The "_get_data()" sub can be called by various methods defined elsewhere in this object's package, and when it's called, the content of $object_data will be returned. But that scalar variable is out of scope, hence inaccessible, for everything but "_get_data()".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-29 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found