Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

In reply to How do I get an exclusion with grep? by Lady_Aleena

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-20 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found