So, 5 years ago I was trying to solve (efficiently) 80 regexs run over a 10K document. That quest ended in success. Now I am wrestling with filtering out lines of an array that match any entry of an array of regexs I am giving 'grep' a shot but am having a problem generalizing a single test into multiple tests.

--Thanks---
Thanks for the quick response. Another nifty tool!!

Perldoc shows:

@foo = grep {!/^#/} @bar; # weed out comments
I want to replace that single regex with a loop over an array of 'qr's.
my @regs =( qr/split/ , qr/se.d/ , qr/open/, qr/print/, # might be another 100 in here # ); my @bar; my @foo; push @foo, "still empty"; open INP , "<../IPutils.pm"; #random code while (<INP>){ push @bar, $_; } print @bar, "\n--EOD-----------\n"; @foo = grep{ # !/^\s*#/ #sample from Perldocs #{ #causes compile error #( #causes compile error my $final =1; #default true foreach my $r (@regs){ $final = 0 if ( $r ); #match means drop this line } $final; #last value of the block hmmmmm #) #} }@bar; print @foo;
'return' shouldn't be the correct mechanism to tell grep true/false. But when I run this, the second print (@foo) produces nothing.

It is always better to have seen your target for yourself, rather than depend upon someone else's description.


In reply to grep with looped tests by Wiggins

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.