Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Answer: How can I create private object variables?

by pemungkah (Priest)
on Nov 08, 2006 at 01:46 UTC ( #582757=categorized answer: print w/replies, xml ) Need Help??

Q&A > object-oriented programming > How can I create private object variables? - Answer contributed by pemungkah

Inside-out classes are another nice way to do this. The data is held in a my (lexical) variable inside the class; all the outside world sees is an anonymous scalar which is blessed into the class. The methods can access the class lexicals (as long as they're defined within scope of the lexicals), but the outside world can't.

See Class::Std and Object::InsideOut for examples.

  • Comment on Answer: How can I create private object variables?
Log In?

What's my password?
Create A New User
and the universe expands...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2018-03-18 23:03 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (231 votes). Check out past polls.