Sorry, I am a PERL newb. I am trying real hard to get this, but to no avail.

I have two multidemensional arrays created from querying Oracle.

I hope this makes sense.

How do I link the two arrays based on @avg12_cost_array.@avg12_cost_c_1_item equals @book_det_array.@book_det_D_item

to add @avg12_cost_array.@avg12_cost_12M_UNIT_COST to @book_det_array

1st array:

while (@row = $sth_2->fetchrow_array) { $c_1_ITEM =~ s/\s*$//; if ($c_9_12M_UNIT_COST =~ /\./) { $c_9_12M_UNIT_COST = sprintf("%.2f", $c_9_12M_UNIT_COST); } push(@avg12_cost_c_1_item, $c_1_ITEM); push(@avg12_cost_12M_UNIT_COST, $c_9_12M_UNIT_COST); # print "$c_1_ITEM, $c_9_12M_UNIT_COST\n"; } $sth_2->finish(); @avg12_cost_array = ( [@avg12_cost_c_1_item], [@avg12_cost_12M_UNIT_CO +ST], ); second array: $sth_3->fetchrow_array; while (@row = $sth_3->fetchrow_array) { # remove trailing spaces $D_agc =~ s/\s*$//; $D_market =~ s/\s*$//; $D_analysis_code =~ s/\s*$//; $D_item =~ s/\s*$//; $D_customer =~ s/\s*$//; $D_key_val2 =~ s/\s*$//; $D_key_val3 =~ s/\s*$//; $D_terms_code =~ s/\s*$//; $D_audit_seq =~ s/\s*$//; $D_aud_date =~ s/\s*$//; $D_aud_time =~ s/\s*$//; $D_opr_id =~ s/\s*$//; $D_action =~ s/\s*$//; $D_column_name =~ s/\s*$//; $D_new_value =~ s/\s*$//; $D_old_value =~ s/\s*$//; $D_tot_canc_qty =~ s/\s*$//; $D_tot_ord_qty =~ s/\s*$//; $D_tot_ship_qty =~ s/\s*$//; $D_ship_complete =~ s/\s*$//; $D_unit_price =~ s/\s*$//; # define PL field ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $mkt_1 = substr $D_market, 0, 1; if ($mkt_1 == "1") { $dPl = "A&D"; } else { $dPl = "MCP"; } push(@book_det_dPl, $dPl); push(@book_det_agc, $D_agc); push(@book_det_D_market, $D_market); push(@book_det_D_analysis_code, $D_analysis_code); push(@book_det_cur_per_month, $cur_per_month); push(@book_det_D_item, $D_item); push(@book_det_D_customer, $D_customer); push(@book_det_D_key_val2, $D_key_val2); push(@book_det_D_key_val3, $D_key_val3); push(@book_det_D_terms_code, $D_terms_code); push(@book_det_D_unit_price, $D_unit_price); push(@book_det_D_audit_seq, $D_audit_seq); push(@book_det_D_aud_date, $D_aud_date); push(@book_det_D_aud_time, $D_aud_time); push(@book_det_D_opr_id, $D_opr_id); push(@book_det_D_action, $D_action); } $sth_3->finish(); # Consolidate the information into an array @book_det_array = ( [@book_det_dPl], [@book_det_agc], [@book_det_D_market], [@book_det_D_analysis_code], [@book_det_cur_per_month], [@book_det_D_item], [@book_det_D_customer], [@book_det_D_key_val2], [@book_det_D_key_val3], [@book_det_D_terms_code], [@book_det_D_unit_price], [@book_det_D_audit_seq], [@book_det_D_aud_date], [@book_det_D_aud_time], [@book_det_D_opr_id], [@book_det_D_action] );
Thanks! Patrick

In reply to Linking and Combining Two Arrays by roguez33

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.