in reply to Improved CGI Design

Use a loop to march through your table; untested code below, but it should get you started.

sub dispatch_table { my $q = shift; my %dispatch = ( add => { confirm => { commit => \&commit_dialog, default => \&confirm_dialog, }, default => \&update_dialog, }, remove => { confirm => { commit => \&commit_dialog, default => \&confirm_dialog, }, default => \&choose_dialog, }, modify => { update => { confirm => { commit => \&commit_dialog, default => \&confirm_dialog, }, default => \&update_dialog, }, default => \&choose_dialog, }, default => \&action_dialog ); for (qw/action confirm commit update/) { if (! exists $dispatch{$q->param($_)}) { return $dispatch{default}; } else { my $ref = $dispatch{$q->param($_)}; if (ref $ref eq "CODE") { return $ref; } elsif (ref $ref eq "HASH") { %dispatch = %{$ref}; } else { die "Our dispatch hash is messed up." } } } return $dispatch{default}; }

perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'