There is no switch statement in Perl. The following is an implementation
of a switch statement using labels and do statements.
SWITCH: for (ref $whatchamacallit) {
/^$/&& die "not a reference";
/SCALAR/&& do {
print_scalar($$ref);
last SWITCH;
};
/ARRAY/ && do {
print_array(@$ref);
last SWITCH;
};
/HASH/ && do {
print_hash(%$ref);
last SWITCH;
};
/CODE/ && do {
warn "can't print function ref";
last SWITCH;
};
# DEFAULT
warn "User defined type skipped";
}