#!/usr/bin/perl -w # switch-example -- a simple switch example, in perl. # # for more info, see: http://language.perl.com/misc/fmswitch use strict; my $choice = 1; while ($choice > 0) { print <; chomp $choice; # here's the actual "switch": SWITCH: for ($choice) { /1/ && do { print "hi mom\n"; last SWITCH }; /2/ && do { print "hi dad\n"; last SWITCH }; /3/ && do { print "hi mom and dad\n"; last SWITCH }; /0/ && last SWITCH; # default print "sorry, don't know how to handle choice \"$choice\"\n"; } } exit 0;