To keep this problem from happening again, you might want to look at Quantum::Superpositions, specifically the any() and all() functions.
Eh, no, you don't. Quantum::Superpositions is extremely slow. There's no justification for using Quantum::Superpositions, just to save typing a pair of parenthesis. Here's a benchmark:
#!/usr/bin/perl use strict; use warnings; use Benchmark qw /cmpthese/; use Quantum::Superpositions; our @data1 = "aa" .. "zz"; our @data2 = "AA" .. "ZZ"; my %queries = ( middle => [$data1 [@data1 / 2], $data2 [@data2 / 2]], first => [$data1 [0], $data2 [0]], not => ["feeble", "fnord"], ); foreach my $type (qw /middle first not/) { warn "Running '$type' test.\n"; our ($q1, $q2) = @{$queries {$type}}; our ($a_g, $a_q); cmpthese -1 => { grep => '$a_g = grep ({$q1 eq $_} @data1) && grep ({$q2 eq $_} @data2)', QS => '$a_q = $q1 eq any (@data1) && $q2 eq any (@data2)' +, }; die "Unequal" if $a_g xor $a_q; print "\n"; } __END__ Running 'middle' test. Rate QS grep QS 24.5/s -- -99% grep 2376/s 9588% -- Running 'first' test. Rate QS grep QS 24.1/s -- -99% grep 2400/s 9869% -- Running 'not' test. Rate QS grep QS 48.6/s -- -99% grep 5744/s 11719% --

Abigail


In reply to Re: multiple greps at once-- possible? by Abigail-II
in thread multiple greps at once-- possible? by sulfericacid

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.