*apple_proc = sub { my $item = shift; apple_wash($item); apple_core($item); apple_pulp($item); }; # same for bananas here. #### foreach my $item (@items) { SWITCH: for ($type) { # not sure from the writeup where # $type is supposed to come from /apple/ && do { apple_proc($item); }; /banana/ && do { banana_proc($item); }; warn "Unknown thingy: $type\n"; # Default case } }