# SWITCH: for(thing to check) { # /regexp/ && do { condition 1; last SWITCH; }; # (condition) && do { condition 2; last SWITCH; }; # do { catch all }; # } #### $ref = \@array; # or, $ref = \%hash; # or, $ref = \$scalar; SWITCH: for(ref $ref) { # check variable type of referent # $ref is still our reference scalar # now $_ contains the referent variable type # (eg, ARRAY, SCALAR, HASH, or object class) /array/i && do { # do something with @$ref last SWITCH; }; /scalar/i && do { # do something with $$ref last SWITCH; }; /hash/i && do { # do something with %$ref last SWITCH; }; do { # panic, we have no handler for this variable type! die "don't know what to do with ". $_; }; }