my %commands = ( opt1 => "exe1", opt2 => "exe2", opt3 => "exe3", ); my $runmode = $cgi->param("runmode"); if(exists $commands{$runmode} ) { system( $commands{$runmode}, $arg1, $arg2 ); if($?) { handle_error(); } } else { handle_error(); # invalid $runmode }