#!/usr/bin/perl use strict; use warnings; use CGI ':cgi'; use Template; # for producing output. # List of subroutines that handle the different modes my %modes = ( mode1 => \&process_mode1, mode2 => \&process_mode2, default => \&process_default, ); # Work out which mode we're in my $mode = param('mode'); # If we have a mode, then call that subroutine if ($mode && %modes{$mode}) { $modes{mode}->(); } else { # Otherwise call the default handler $modes{default}->(); } sub process_default { # no mode give, display the default form } sub process_mode1 { # process mode1 and display the next form } sub process_mode2 { # process mode2 and display the next form }