#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my $params = { param1 => 1, param2 => 2, }; my ($case, $args) = process_params($params); my %dispatch_table = ( case1 => \&case1, case2 => \&case2, default => \&default, ); my $page_header = page_header(); my $body = $dispatch_table{$case}->($args); my $page_footer = page_footer(); print $page_header, $body, $page_footer; sub process_params{ my $params = shift; my $case = q{default}; my $args = {}; if ($params->{q{param1}} eq 1){ $case = q{case1}; } elsif ($params->(q{param2}) eq 2){ $case = q{case2}; } else{ $case = q{default}; } return $case, $args; } sub case1 { my $args = shift; my $output = qq{case one\n}; return $output; } sub case2 { my $args = shift; my $output = qq{case two\n}; return $output; } sub default { my $args = shift; my $output = qq{default\n}; return $output; } sub page_header { my $ph = qq{page header\n}; return $ph; } sub page_footer { my $pf = q{page footer}; return $pf; }