foreach my $f($query->param) {
foreach my $v($query->param($f)) {
switch($f) {
case 'a' {
switch($v) {
case 1 { code1; }
case 2 { code2; }
case 3 { code3; }
}
case 'b' {
switch($v) {
case 1 { code4; }
case 2 { code5; }
}
case 'c' {
switch($v) {
case 1 { code6; }
case 2 { code7; }
case 3 { code8; }
case 4 { code9; }
}
}
}
}
}
foreach my $f($query->param) { foreach my $v($query->param($f)) { switch($f) { case ‘a’ { switch($v)
Share
Above all… DO NOT USE Switch.pm. If you are using Perl 5.10 or newer, given/when is a native switch statement.
A dispatch table is the solution you seek. http://www.perlmonks.org/?node_id=587072 describes dispatch tables, a technique for executing code via a hash based on some value matching the hash key.
Edit, example: