"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
!~ will return true if the thing on the right does not match.
In your case, however, using unless seems more logical. 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''. Make sure that you
Chad Perrin wrote:
> On Fri, Dec 29, 2006 at 11:36:25PM -0500, Mathew Snyder wrote:
>> I'm trying to set up an if clause to exit if an answer given is anything but
>> either any case combination of 'y' or 'yes'. This is what I have:
>>
>> exit if $ans =~ m/[^y|^yes]/i;
>>
>> Will that do what I wa
On Fri, Dec 29, 2006 at 11:36:25PM -0500, Mathew Snyder wrote:
> I'm trying to set up an if clause to exit if an answer given is anything but
> either any case combination of 'y' or 'yes'. This is what I have:
>
> exit if $ans =~ m/[^y|^yes]/i;
>
> Will that do what I want?
If you want anything
Mathew Snyder wrote:
Ken Foskey wrote:
On Fri, 2006-12-29 at 23:36 -0500, Mathew Snyder wrote:
I'm trying to set up an if clause to exit if an answer given is anything but
either any case combination of 'y' or 'yes'. This is what I have:
exit if $ans =~ m/[^y|^yes]/i;
exit if $ans =~ m/^(y|
Ken Foskey wrote:
> On Fri, 2006-12-29 at 23:36 -0500, Mathew Snyder wrote:
>> I'm trying to set up an if clause to exit if an answer given is anything but
>> either any case combination of 'y' or 'yes'. This is what I have:
>>
>> exit if $ans =~ m/[^y|^yes]/i;
>>
>
> exit if $ans =~ m/^(y|yes)[
Ken Foskey wrote:
> On Fri, 2006-12-29 at 23:36 -0500, Mathew Snyder wrote:
>> I'm trying to set up an if clause to exit if an answer given is anything but
>> either any case combination of 'y' or 'yes'. This is what I have:
>>
>> exit if $ans =~ m/[^y|^yes]/i;
>>
>
> exit if $ans =~ m/^(y|yes)[
Ken Foskey wrote:
> On Fri, 2006-12-29 at 23:36 -0500, Mathew Snyder wrote:
>> I'm trying to set up an if clause to exit if an answer given is anything but
>> either any case combination of 'y' or 'yes'. This is what I have:
>>
>> exit if $ans =~ m/[^y|^yes]/i;
>>
>
> exit if $ans =~ m/^(y|yes)[
On Fri, 2006-12-29 at 23:36 -0500, Mathew Snyder wrote:
> I'm trying to set up an if clause to exit if an answer given is anything but
> either any case combination of 'y' or 'yes'. This is what I have:
>
> exit if $ans =~ m/[^y|^yes]/i;
>
exit if $ans =~ m/^(y|yes)[ \t\r\n]*$/i;
The brackets