in reply to Yes No Validation
Your regexps are matching anything that starts with 'y' or 'n' (any case). Just expand and anchor the matches to look like this:
if (/^y|yes|n|no$/i) { if (/^no?$/i) { print "Begone, evil peon!\n" } if (/^y(es)?$/i) { print "YIPPEEE.!!!!\n"; } } else { # Validate user input and return message if invalid print "\n\n=====================================\n"; print "You Have Entered and Incorrect Option\n"; print "Valid Options are [Y/N]\n"; print "=====================================\n\n"; &answer; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Yes No Validation
by LAI (Hermit) on Feb 06, 2003 at 20:52 UTC |