in reply to Pseudo-switch question
Well, the example given in perlfaq7 (perldoc -q switch) is a bit easier for me to read:
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"; }
Seems pretty much the same as what you're doing, as far as functionality, just a little prettier...
Update: Added more thoughts:
I can't see any performance hit. All you're really doing is assigning your test to $_ so that you can make testing it prettier.
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pseudo-switch question (yuck)
by tye (Sage) on Jul 23, 2003 at 07:57 UTC |