use MySite::SubClass; my $webapp = MySite::SubClass->new(); $webapp->run(); #### package MySite::SubClass; use MySite::SuperClass; sub setup { # setup runmodes and script specific stuff # ...templates perhaps? } # … # runmodes subs and whatnot :) # … 1; #### package MySite::SuperClass; use base 'CGI::Application'; use CGI; # other modules here.. sub cgiapp_init { my $self = shift; # create database handler # do session management } sub teardown { my $self = shift; # dbh->disconnect } # … # other functions # … 1;