{ my %_attr = { _attr1 => 'read', _attr2 => 'write', } sub _accessible { my ($self, $attr, $mode) = @_; $_attr{$attr} =~ /$mode/; } } #### sub AUTOLOAD { my ($self, $value) = @_; ## was it a get method? $AUTOLOAD =~ /.*::get(_\w+)/ and $self->_accessible($1, 'read') and return $self->{$1}; ## was it a set method? $AUOTLOAD =~ /.*::get(_\w+)/ and $self->_accessible($1, 'write') and do { $self->{$1} = $value; return} die "No such method: $AUTOLOAD, $!"; }