in reply to simple loop
use strict; use warnings; my $choice; while (1) { print "Please type in 1, 2 or 3 and press enter: "; chomp ($choice = <STDIN>); last if (($choice eq "1") or ($choice eq "2") or ($choice eq "3")); print "Sorry that was invalid.\n\n"; } print "\nThank you, you entered $choice.\n\nPress ENTER to exit\n"; <STDIN>;
|
|---|