if( $var =~ m/\A ( yes | no ) \z/x ) { print "you chose $1\n"; } else { print "BAD USER, NO DONUT!\n"; }