my %dispatch = ( DoThis => sub { print "You asked me to do this.\n"; }, DoThat => sub { print "You asked me to do that.\n"; } ); #### SWITCH: for ( @commands ) { m/^This/ && do { print "You asked me to do this.\n"; next SWITCH; }; m/^That/ && do { print "You asked me to do that.\n"; next SWITCH; }; m/^Another/ && Another_Way(); m/^Quit/ && do { print "Goodbye.\n"; last SWITCH; } sub Another_Way { print "You asked me to do it another way.\n"; }