roguez33 has asked for the wisdom of the Perl Monks concerning the following question:
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:
Thanks! Patrickwhile (@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] );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Linking and Combining Two Arrays
by merlyn (Sage) on Feb 01, 2010 at 18:39 UTC | |
by roguez33 (Initiate) on Feb 01, 2010 at 18:51 UTC | |
by toolic (Bishop) on Feb 01, 2010 at 19:07 UTC | |
|
Re: Linking and Combining Two Arrays
by Cristoforo (Curate) on Feb 01, 2010 at 22:39 UTC | |
by roguez33 (Initiate) on Feb 02, 2010 at 02:43 UTC | |
by Cristoforo (Curate) on Feb 03, 2010 at 01:28 UTC | |
by roguez33 (Initiate) on Feb 03, 2010 at 15:29 UTC | |
by Cristoforo (Curate) on Feb 05, 2010 at 17:28 UTC | |
|