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


in reply to a simple matter of elegance

You could create closures for each of the attributes and add them to the package's namespace:
package Foo; use warnings; use strict; foreach my $att (qw/name address age sex geek_code/) { no strict 'refs'; *$att = sub { my $self = shift; return $self->{data}->{$att}; }; }