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 but a given pattern, the best way to do it is
usually by using the !~ operator.  Thus, if you have a pattern $foo,
this matches that pattern:

  exit if $ans =~ m/$foo/i;

. . . while this matches anything but that pattern:

  exit if $ans !~ m/$foo/i;

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
"A script is what you give the actors.  A program
is what you give the audience." - Larry Wall

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


Reply via email to