http://qs321.pair.com?node_id=11116100

Lady_Aleena has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to exclude certain items with grep, however, my exclusion is not working.

Here is the snippet I am working on where I do not want the string  right appended if the word in the $text appears in one of the items in the list. Everything is getting  right appended currently.

my @big_images = $opt{big} ? @{$opt{big}} : (); for my $cross_file (@cross_files) { my $text = textify($cross_file); my $class = 'svg_group'; $class .= ' right' unless grep(/$text/i, @big_images); }

So, if I use it like the following, I do not want right appended to $class if Smart is in $text.

my $magic = crossover_magic( big => ['Smart'] );

Update: 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.

Here is the whole subroutine if there is something in there that might be affecting things that I am not seeing.

sub crossover_magic { my %opt = @_; our $magic; my $open_directory = file_directory('Fandom/Crossovers', 'imagesd'); my $link_directory = file_directory('Fandom/Crossovers', 'images'); my @cross_files = file_list($open_directory); my @big_images = $opt{big} ? @{$opt{big}} : (); for my $cross_file (@cross_files) { my $link = "$link_directory/$cross_file"; my $text = textify($cross_file); my $class = 'svg_group'; $class .= ' right' unless grep(/$text/i, @big_images); my $title = "$text chart"; $magic->{$text} = sub { figure(6, sub { line(7, anchor( '', { 'href' => $link, 'target' => 'new' })); line(7, object( '', { 'data' => $link, 'type' => 'image/svg+xm +l'})); }, { 'class' => "$class", 'title' => $title }); }; } my $series = series('data', 'me'); my $series_list = movie_option('series'); for my $item (sort keys %$series_list) { my $magic_search; my $magic_text; if ($series->{$item}) { for my $program (@{$series->{$item}->{programs}}) { my $magic_key = $item eq $program ? "$program-single" : $pr +ogram; $magic_text = textify($program); $magic_search = searchify($item, [$program]); $magic->{$magic_key} = qq(A<I<$magic_text>|href="../../Movies/ +Movies_by_series.pl?series=$magic_search">); } } $magic_text = $item eq 'Scorpion' ? '&#60;/Scorpion&#62;' : $item eq 'EUReKA' ? 'EURSUP<e>KA' : textify($item); $magic_search = searchify($item); $magic->{$item} = qq(A<I<$magic_text>|href="../../Movies/Movies_by +_series.pl?series=$magic_search">); } return $magic; }

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