Alright, I'm working in a few hundred lines of code here that would take exponentially longer to sanitize and create data sets to 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.

I have two arrays. Array one is the finished product of the script.....except it has a ton of extraneous data that I don't want, and has proven incredibly hard to prevent from being entered into the array. Enter array two, my filter.

Array_1 [0] = master_id [1] = sub_id1 [2] = sub_id2 [3] = sub_id3 [4] = sub_id4 Array_2 [0] = data [1] = sub_id

What I need to do is take Array 1 and recreate it for [ 0 ],[ 1 ],[ 2 ],[ 3 ],[ 4 ] for each entry where [ 1 ] or [ 3 ] matches any of the [ 1 ]'s in Array 2

is that straightforward enough? Sorry for the crap post, I'm on a time crunch and traveling away from my notes on this script. Brain is fried.

OOOOH, and while we're at it, lets add a [ 5 ] and [ 6 ] to array 1 that stores any matching [ 0 ] from array 2 for that sub_id!

final filtered output if sub_id1 or sub_id3 exist in array 2: Array_3 [0] = master_id [1] = sub_id1 [2] = sub_id2 [3] = sub_id3 [4] = sub_id4 [5] = sub_id1_data [6] = sub_id2_data

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