G'day Lady Aleena,

Without knowing the exact contents of @big_images and @cross_files, or what transformation occurs when textify() is run, it's not possible to give a direct answer.

As a first step, I recommend you print those values inside delimiters to identify parts of the string that may not be immediately obvious. For example, these may appear the same when printed directly:

$ perl -E 'say for "qwe", "qwe\n"' qwe qwe

With delimiters, the difference is obvious:

$ perl -E 'say "|$_|" for "qwe", "qwe\n"' |qwe| |qwe |

Doing this may highlight the problem and allow you to solve it yourself. If not, post the results and we can have another look at it.

You're reading the entirety of @big_images in every iteration of the for loop. A slightly more efficient way would be to only read as much as you need: see the List::Util function first. Not reading that array at all inside the for loop would be much better; something like:

my %big_image = map +(fc($_) => 1), $opt{big} ? @{$opt{big}} : (); for my $cross_file (@cross_files) { my $text = textify($cross_file); my $class = 'svg_group'; $class .= ' right' unless exists $big_image{fc $text}; }

Note: Testing $opt{big} for truth may be an issue. If --big (I'm guessing at the option) isn't supplied, will the key, big, be absent or will it have an empty arrayref ([]) as its value? If it's an empty arrayref, the value (something like ARRAY(0xhhhhhhhh)) will always be true and a better test would be 0+@{$opt{big}}.

$ perl -E 'my %opt = ( big => [] ); say $opt{big}' ARRAY(0x600003a90) $ perl -E 'my %opt = ( big => [] ); say 0+@{$opt{big}}' 0

However, if the key is absent, a better test would be exists($opt{big}).

Depending on other code not shown, a combination of both of those (exists($opt{big}) && 0+@{$opt{big}}) may be even better.

— Ken


In reply to Re: How do I get an exclusion with grep? by kcott
in thread 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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.