Perl (just a quick fix)
A fix to rubber boots' solution, being a new user that I am I can't comment yet so I'll just post a new answer.
As the mentioned method uses a regular expression constructed from user input, it is possible to perform a small regex injection, as follows:
> perl -le '$.=pop;$_=(pop)x2;print+(qw/yes no/)[!/$./]' anything '.*'
The fix is to use \Q (known also as quotemeta):
> perl -le '$.=pop;$_=(pop)x2;print+(qw/yes no/)[!/\Q$./]' anything '.*'
The code itself could be further shortened using 'say' but this is left as an exercise to the reader :)