http://www.perlmonks.org?node_id=174802


in reply to basic object question

Instead of using plain old hashes within your object hash, make your object hash contain other objects. Then, you could write Get and Set methods for those.

That might be a pain, though.

My personal preference is not to make anything beyond the first level of the object hash directly useful to the outside. I'll populate the first level with data members and write accessors and mutators for them. Then I'll do something like:

$self->{_private}{'foo'} = Foo->new;

I then make sure that none of my accessors or mutators will return $self->{_private}. Of course, it's not really private, but it works enough for me.