Take a look at the classic
Class::Prototyped (which is the basis of my web framework,
CGI::Prototype), or the more modern
Moose, which will serve as the basis for the metamodel of Perl6. Both of them allow great reflection and introspection, and run-time behavior to dynamically add new member variables.