in reply to Linking and Combining Two Arrays

I am having trouble seeing what you want to do. 'Linking' the arrays doesn't tell me what is you want to achieve. Maybe you could elaborate further on your basic problem.

Could you show us your SELECT statements and maybe I could see how you want to join the results?

Replies are listed 'Best First'.
Re^2: Linking and Combining Two Arrays
by roguez33 (Initiate) on Feb 02, 2010 at 02:43 UTC

    The first table select is for calculated 12 month average cost of parts.

    Output two fields $c_1_ITEM and $c_9_12M_UNIT_COST

    The second is multiple table select for parts date based on current month data.

    Output many fields. $D_item, $D_agc, and etc....

    Parts here being "item". array 1 item "$c_1_ITEM" = array 2 item "$D_item". Add average cost "$c_9_12M_UNIT_COST" to table 2 based on item.

    Array two after - $D_item, $D_agc, c_9_12M_UNIT_COST, and etc.....

    There is not a one to one relationship here, so a push would not work. But every part "item" in table two has a corsponding entry in table one.

    I understand that I probably need to do a hash of hash, but I am not sure how to get there. I suspect a foreach is needed also.

    Thanks!
      You say that you want to add the average cost, which is located in the first table, to the results from table 2. And that for each item in the second table, there is an item in the first table that matches.

      The way you set up the arrays is very uncommon and may not be what you want. The data structure you choose depends in part in what you want to do with the results. Just print them out to a report, perform calculations on them, etc. By looking at the fields you're capturing, these seem to be business statistics. It would be helpful to know what it is you want to do with the results. If each of the variables you set up equaled the number of returned fields, there are about 21 of them.

        I am probably making this more difficult then nescessary. I have been leveraging code done by a previous programmer, as I am very new to PERL.

        I welcome better ideas on how to get the desired output, which is an final excel CSV.

        The avgerage cost is to be used to preform calulations in the second "array" .

        I suspect a foreach loop next to pull in average cost and caluculate new fields. Caluclate a couple of other fields based on available data and then output to CSV.