in reply to How do I get an exclusion with grep?

I found that $text needs to be an exact match. I would prefer not having to use exact matches. I added case insensitivity to it also.

This suggests to me that you might be performing the match the wrong way round, i.e. you want to look case-insensitively within $text for things which match the patterns held in @big_images. If that's the case then you need to switch the grep so that $_ becomes the pattern. e.g.:

$class .= ' right' unless grep($text =~ /$_/i, @big_images);

Here's the SSCCE:

use strict; use warnings; use Test::More tests => 4; my $text = 'Only smartees have the answer!'; ok grep ($text =~ /$_/i, 'Smart'), 'Case-insensitive match'; ok grep ($text =~ /$_/i, 'foo', 'Smart', 'bar'), 'Match one of three'; ok grep ($text =~ /$_/i, 'foo', 'Smart', 'art'), 'Match two of three'; ok !grep ($text =~ /$_/i, 'foo', 'baz'), 'Match none';

HTH.

Replies are listed 'Best First'.
Re^2: How do I get an exclusion with grep?
by Lady_Aleena (Priest) on Apr 27, 2020 at 09:22 UTC

    Thank you hippo, that worked! 8)

    My OS is Debian 10 (Buster); my perl version is 5.28.1.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena