use vars qw(%Actions); %Actions = ( read => { subroutine => \&ReadData, template => 'readData_template', }, sendmail => { subroutine => \&SendMail, template => 'sendMail_template', }, # .... default => { subroutine => \&Default, template => 'startPage_template', }, ); # Actions my $cgi = CGI->new(); my $action = $cgi->param('action') || 'default'; if (exists $Actions{$action}->{subroutine} ) { $Actions{$action}->{subroutine}->($cgi, $action); } else { $Actions{default}->{subroutine}->($cgi, $action); }