use CGI related modules; use HTML::Template; use DBI; use Myapp::Authenticate qw(authenticate); use Myapp::View qw(view); use Myapp::Update qw(update); # # you get the picture #### # 1. create objects in the main script and pass them around my $cgi = new CGI::Simple; # unpack $cgi minimally to determine what to do my $action = $cgi->param('action'); my $dbh = DBI->connect(dbi stuff); my $template = HTML::Template->new(logic to determine template); # dispatch if ($action eq 'view') { view($cgi, $dbh, $template); } elsif ($action eq 'save') { save($cgi, $dbh, $template); } yadda yadda # then unpack the objects in the respective modules as needed #-------------------------------------- # 2. don't schlep the objects, but refer to them via fully # qualified names as needed # # create objects as above. unpack $cgi minimally to determine action # dispatch if ($action eq 'view') { view(); } elsif ($action eq 'save') { save(); } yadda yadda # then, in my modules package Myapp::View; sub view { my $target = $main::cgi->param('target'); my $this = $main::cgi->param('this'); my $that = $main::cgi->param('that'); my $sth = $main::dbh->prepare(...); $sth->execute; $main::template->param(RESULTS => $sth->fetchall_arrayref({}),); } #-------------------------------------- # 3. another variation # besides any mix of the above, don't import/export anything. # Refer to everything using their long names.