my $q = new CGI; my %States = ( 'Default' => \&index, 'Index' => \&index, 'Save' => \&save, 'Etc' => \&etc, ); # Query for the value of ".State" as passed by the POST # Method my $current_screen = $q->param(".State") || "Default"; die "No Screen for $current_screen" unless $States{$current_screen}; # iterate through values in %States for active page while (my ($screen_name, $function) = each %States){ $function->($screen_name eq $current_screen); } #generate pages based on sub called sub index { my $active = shift; return unless $active; do_stuff(); }