use CGI; use vars qw(%Actions); %Actions = ( eins => { code => \&Action1, template => 'action1.tmpl', x => 20 }, zwei => { code => \&Action2, template => 'action2.tmpl', a => 30 }, drei => { code => \&Action3, template => 'action3.tmpl', foo => 'bar' }, default => { code => \&Start, template => 'start.tmpl' }, }; my $cgi = CGI->new(); my $action = $cgi->param('action'); if ( defined $action and exists %Actions{$action} ) { $Actions{$action}->{code}->($cgi, $action); } else { $Actions{"default"}->{code}->($cgi, "default"); } #else # -------------------------------- sub Action1 { my ($cgi, $action) = @_; my $template = $Actions{$action}->{template}; ... } # Action1 # -------------------------