[tpm] looking for a regex that returns true on no match

Fulko Hew fulko.hew at gmail.com
Thu Mar 12 07:44:56 PDT 2009


On Thu, Mar 12, 2009 at 10:30 AM, Adam Prime <adam.prime at utoronto.ca> wrote:

>
> Fulko Hew wrote:
>
>> Alex asked:
>>
>>  > Couldn't you just use the ~! on the regex instead of ~=?
>>
>
... snip ...


> it's !~, not ~!
>
> ie:
>
> aprime at primepc:~$ cat haha.pl
>
> my $text = 'haha';
>
> if ($text !~ /hat/) {
>    print qq[yay\n];
> }
> else {
>    print qq[yay\n];
> }
> aprime at primepc:~$ perl haha.pl
> yay
>
> also, given your example there, why wouldn't you just
>
> return true unless $_ eq 'good';
>


Because I'm not allowed to rewrite the code, but simply insert a
different regex pattern in between the slashes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20090312/2acf10e2/attachment-0001.html>


More information about the toronto-pm mailing list