my $re = qr!yes|no!; print "yes or no!\n" if "yes" =~ $re; print "yes or no only" if "maybe" !~ $re; print "polite yes or no\n" if "yes thankyou" =~ /$re thankyou/;