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; }
In reply to Re: Yes No Validation
by steves
in thread Yes No Validation
by J9
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |