foreach my $itemcode (keys %inventory) { my $quantity = $inventory{$itemcode}[2]; if ( $quantity > 0 )