## index.cgi use strict; use CGI::Simple; use HTML::Template; use MyPackage; # The following are imported from the .conf file below use vars qw( $WIKI_TITLE $CGIURL $DB $TEMPLATE_PATH $TEMPLATE_URL $DEFAULT_TARGET $DEFAULT_ACTION $DEBUGGING $PAGENAME_PATTERN $EMAIL_PATTERN $CGIPATH ); # A set_message handler allows creation of a nice looking, # custom error page. This is based on the example # provided in CGI::Carp docs BEGIN { require 'home.conf'; sub handleErrors { my ($err) = @_; my $t = HTML::Template->new( filename => "$TEMPLATE_PATH/error.tmpl", ); $err =~ s/$CGIPATH //g; $t->param( CGIURL => $CGIURL, TEMPLATE_URL => $TEMPLATE_URL, WIKI_TITLE => $WIKI_TITLE, PAGENAME => 'Error', ERROR => $err, ); print $t->output; } set_message(\&handleErrors); } yadda yadda # grab the cgi vars my $cgi_action = $cgi->param('action'); yadda yadda ## dispatch table follows # Dispatch logic SWITCH: { ($cgi_action eq 'edit') && do { edit($cgi_target, $cgi_searchterm); last SWITCH; }; ($cgi_action eq 'find') && do { find($cgi_target, $cgi_searchterm); last SWITCH; }; yadda yadda # default action view($cgi_target, $cgi_searchterm); } #### ## index.cgi use strict; use CGI::Simple; use HTML::Template; use MyPackage; ## and then, in MyPackage use MyPackage::View; use MyPackage::Edit; use MyPackage::Find; yadda yadda