package Foobar; use strict; sub new { my $self = bless {}, shift; $self->init; } sub init { my $self = shift; $self->{build} = 1; $self->{version} = '1.0 alpha'; require CGI; $CGI::HEADERS_ONCE = 1; $self->{cgi} = CGI->new; require fbconfig; $self->{cfg} = fbconfig->get; # this is where I load the config from fbconfig.pm (saved by the sub save_config) return $self; } sub run { # A page handler would go here } sub save_config { my $self = shift; use Data::Dumper; $Data::Dumper::Terse = 1; open XCFG, '>fbconfig.pm'; print XCFG "package fbconfig;\n\n"; print XCFG "sub get {\n return ", Dumper($self->{cfg}), ";\n\n}\n\n1;"; close XCFG; } 1;