package My::Base; use My::Config; sub new { my $self = { }; bless $self , 'My::Base'; } sub config { my ($self) = @_; my $config = My::Config->new(); return $config; } sub AUTOLOAD { my ( $self, $value ) = @_; $AUTOLOAD =~ /.*::(\w+)/; my $command = $1; if ( defined($value) ) { $self->config->$command($value); return; } else { return $self->config->$command; } } 1;