Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
my @inventory_items_array; my $inventory_item; my %stock_current; my %stock_minimum; while ($inventory_item = $sth->fetchrow_hashref()){ $stock_current{$inventory_item->{'inventory_item_id'}} = $inve +ntory_item->{'starting_quant'}; $stock_minimum{$inventory_item->{'inventory_item_id'}} = $inve +ntory_item->{'starting_quant'}; $inventory_item->{'search'} = join(',', $inventory_item->{'nam +e'}, $inventory_item->{'description'}, $inventory_item->{'inventory_i +tem_id'}); push(@inventory_items_array, $inventory_item); } my $stock_change_data_ref; while ($stock_change_data_ref = $stock_change_sth->fetchrow_hashre +f()){ $stock_current{$stock_change_data_ref->{'inventory_item_id'}} ++= $stock_change_data_ref->{'Qty_Change'}; if ($stock_current{$stock_change_data_ref->{'inventory_item_id +'}} < $stock_minimum{$stock_change_data_ref->{'inventory_item_id'}}){ $stock_minimum{$stock_change_data_ref->{'inventory_item_id +'}} = $stock_current{$stock_change_data_ref->{'inventory_item_id'}}; } } foreach(@inventory_items_array){ $_->{'rem_avail_quant'} = $stock_minimum{$_->{'inventory_item_ +id'}}; $_->{'available'} = $_->{'rem_avail_quant'} . '/' . $_->{'inv_ +quant'}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Optimizing Loop
by davido (Cardinal) on Feb 17, 2014 at 23:27 UTC | |
|
Re: Optimizing Loop
by LanX (Saint) on Feb 17, 2014 at 23:14 UTC | |
by Anonymous Monk on Feb 18, 2014 at 10:34 UTC | |
|
Re: Optimizing Loop
by bulk88 (Priest) on Feb 18, 2014 at 05:26 UTC |