- or download this
for ($variable_to_test) {
if (/pat1/) { } # do something
...
elsif (/pat3/) { } # do something else
else { } # default
}
- or download this
SWITCH: for (ref $whatchamacallit) {
...
warn "User defined type skipped";
}
- or download this
chomp($answer = <>);
if ("SEND" =~ /^\Q$answer/i) { print "Action is send\n" }
...
elsif ("ABORT" =~ /^\Q$answer/i) { print "Action is abort\n" }
elsif ("LIST" =~ /^\Q$answer/i) { print "Action is list\n" }
elsif ("EDIT" =~ /^\Q$answer/i) { print "Action is edit\n" }
- or download this
my %commands = (
"happy" => \&joy,
...
} else {
print "No such command: $string\n";
}