"Leonid Grinberg" schreef:

> Something like
>
> exit unless (lc($answer) =~ /^[y|yes]$/)
>
> should work. The ^ and $ are there to make sure that the string
> contains nothing but ``y'' or ``yes''.

No. Your "[y|yes]" is equivalent to "[|esy]" and matches a single
character.

I guess you meant

  /^(?:y|yes)$/

which can also be written as

  /^y(?:es)?$/

or, if you don't mind the capturing, as

  /^y(es)?$/

-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to