for each entry where [ 1 ] or [ 3 ] matches any of the [ 1 ]'s in Array 2

Sorry, but even after re-reading your post twice, this part of the explanation doesn't make sense to me, what is this "[ 1 ] or [ 3 ]" - why should sub_id only match indicies 1 and 3, and/or why does your sample output include all of Array_1 plus the entries sub_id1_data and sub_id2_data (note the emphasis)? And what does "any of the [ 1 ]'s" mean, I see only one entry at each index 1? If you could explain more - best of course with example input, runnable code, and expected output for that input - we could be of more assistance.

For now, I can only guess that you might want to build a regex out of Array_2 and grep Array_1 with that regex, and for the second part of your question pushing the results back onto Array_1.

provide a functional snippet....so I'm not going to. I think the question is easy enough to pose, so I'm hoping I don't get too many "follow all the rules" replies.

The "rules"* are not there just for the sake of being rules or because we like being picky (although that often comes with the territory in programming ;-) ), but because experience has shown it's the most straightforward way to see the problem and provide help, and sorry but your post is another example of that - see my questions above, for example, if the confusion results from typos in the indicies, runnable code would have caught that. So: I know what I mean. Why don't you? How do I post a question effectively? and Short, Self-Contained, Correct Example.

* Update: Don't think of them as "rules", but as advice to help post good questions. Good questions are not good because they followed all the rules, but because they efficiently provide all the information needed to get good answers. It may be a cliche but in this case it's extremely fitting: Help us help you. (We're all here voluntarily.) Plus, the process of crafting a good question itself will often bring you closer to the answer, since for example cutting your code down to an SSCCE is the same as one would do when debugging anyway.


In reply to Re: Filtering array based off of two values against second array by haukex
in thread Filtering array based off of two values against second array by Speed_Freak

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.