package MyApp::Config; use vars qw($ActionsHRef); use Readonly $ActionsHRef => { default => { subroutine => \&ActionDefault, template => 'action_default.tmpl', }, overview => { subroutine => \&ActionOverview, template => 'action_overview.tmpl', maxEntriesPerPage => 40, }, # ... }; package main; # hauptprogramm use CGI; my $cgi = CGI->new(); my $action = $cgi->param('action') || 'default'; # action nie 0 my $dbh = DBI->connect($dsn, $user, $pw) or die ...; my $subRef; if( exists $MyApp::Config::ActionsHRef->{$action} ) { $subRef = $MyApp::Config::ActionsHRef->{$action}->{subroutine}; } # if else { $subRef = $MyApp::Config::ActionsHRef->{'action_error'}; } # else my ($templateFile, $params) = $subRef->( $cgi, $dbh, $action ); print $cgi->header(); my $template = &ReadAndFillTemplate( $templateFile, %DefaultParams, %$params ); $template->output(); # ----------------------------------------- sub ActionDefault { my ($cgi, $dbh, $action) = @_; # mach was... my %params = (p1 => 'v1', p2 => 'v2'); return ($MyApp::Config::ActionsHRef->{$action}->{template}, \%params); } # ActionDefault