>> At 08:30 AM 7/13/2005, Hugh Loebner wrote: >> >> Why on earth are you using a goto statement? They are pernicious. > > We have a goto in our code. I hate it, but there just isn't a good > "switch" or "case" statement in Perl yet (I think I've heard that it's > planned)
It's not a case/switch, but you can do the same kind of thing with a hash: my %hash = ( sub1 => 'dothis', sub2 => 'dothat', ); print "Choose a sub: sub1, sub2: "; chomp(my $choice=<STDIN>); if ($choice !~ /^sub[12]$/) { &badchoice; } else { &{$hash{$choice}}; } sub dothis { print "You selected to dothis!\n"; } sub dothat { print "You selected to dothat!\n"; } sub badchoice { print "You don't follow directions very well.\n"; } _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs