sub AUTOLOAD { my ($self) = @_; $AUTOLOAD =~ /.*::get(_\w+)/ or croak "No such method: $AUTOLOAD"; $self->_accessible($1) or croak "No such attribute: $1"; $self->{_read_count}++; return $self->{$1} } #### { my %_attrs = ( _name => undef, _artist => undef, ); sub _accessible { exists $_attrs{$_[1]}} }