eval { my $foo = OurParentPackage->new; $SIG{__WARN__} = sub { die @_ }; $foo->initialize; $foo->run; }; if ($@) { print "content-type: text/html\n\n$@"; exit; } package OurParentPackage; sub new { bless { }, shift; } sub initialize { my $self = shift; require CGI; $self->{CGI} = new CGI; $self->{Config} = { 'this' => 'that' }; # config hash would be loaded here. # and some 'global' stuff.... $self->{script_build} = 1; $self->{script_version} = '1.0 alpha'; return $self; } sub run { my $self = shift; if ($self->{CGI}->param('area') eq 'widgetone') { if ($self->{CGI}->param('act') eq 'add') { WidgetOne->add; } else { WidgetOne->default; } } elsif ($self->{CGI}->param('area') eq 'widgettwo') { if ($self->{CGI}->param('act') eq 'add') { WidgetTwo->add; } else { WidgetTwo->default; } } elsif ($self->{CGI}->param('area') eq 'widgetthree') { # etc.... } } package WidgetOne; sub default { my $self = shift; ############ # the below line wont work because it needs the the above subs $self. I need to get its $self here somehow without re-running OurParentPackage's initialize sub. print $self->{CGI}->header; ############ } sub add { my $self = shift; # code to add a 'WidgetOne' would go here. } package WidgetTwo; sub default { my $self = shift; # the default 'WidgetTwo' page code would be here... } sub add { my $self = shift; # code to add a 'WidgetTwo' would go here. } package WidgetThree; sub default { my $self = shift; # the default 'WidgetThree' page code would be here... } sub add { my $self = shift; # code to add a 'WidgetTwo' would go here. }