sub new { # Stuff up here foreach my $attrib (keys %$self) { my $conv_attrib = $attrib; $conv_attrib =~ s/^_(\w+)$/lc $1/e; no strict 'refs'; *{__PACKAGE__ . "::$conv_attrib"} = gen_closure($attrib); } return $self; } sub gen_closure { my $attrib = shift; return sub { my $self = shift; if (@_) { $self->{$attrib} = shift; } return $self->{$attrib}; } }