I'm trying to test two different pieces of data at once using an unless (grep .. grep) and was wondering if it's possible. Some of you may tell me to try such a thing before asking, but that's why I'm here. I am getting unexpected results and after thorough testing, I can't see where else the mistake lies.
unless ( grep{$test1 eq $_} @accepted1 && grep{$test2 eq $_} @accepted +2) {
My tests to see what's going on are simple. I print both $test1 and $test2 along with a foreach(@array) for both sets
print "you had test1: $test1<br>"; foreach(@test1) { print "$_<br>"; } print "<br>you had test2: $test2<br>"; foreach(@test2) { print "$_<br>"; }
And the tests come back positive. Test1 matches perfectly with an item that worked in the first array (this was working properly until I decided to add the 2nd test) and Test2 matches perfectly with an item from it's array too. But something is making it fail.

Is this grep doing something I'm not seeing? Only idea I can come up with is it's testing just the first item in both arrays and if they don't match according to what we want, it says it doesn't work instead of going over every array item.

Thanks for your help, wise monks.



"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

In reply to 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.