package Config::Foo; sub new { my $class = shift; my $fn = shift; ## read the configuration file here ## ... bless $this, $class } sub get { my $this=shift; my $key=shift; my $default=shift; exists $this->{$key} ? $this->{$key} : $default; } sub set { my $this=shift; my $key=shift; my $value=shift; $this->{$key}=$value; } 1; --- package MyApp::Config; use Config::Foo; require Exporter; our @EXPORT=qw(config); our @ISA=qw(Exporter); ## (updated!) my $config; sub config { $config=Config::Foo->new('/etc/myapp.conf') unless defined $config; $config; } 1; --- # and in your app use MyApp::Config; my $foo=config->get(foo); config->set(bar => 'new_bar');