in reply to use of unitialized value
By all means, use the above solutions. But as a general rule, it is easy to add print statements to your code when you have a problem:
foreach my $itemcode (keys %inventory) { my $quantity = $inventory{$itemcode}[2]; print "<$quantity>\n"; # to replace if block }
dave
In Section
Seekers of Perl Wisdom