use Carp; sub AUTOLOAD { my ($self) = @_; $AUTOLOAD =~ /.*::(\w+)/ && exists $self->{$1} and return $self->{$1}; croak "No such attribute: $1"; }