You don't need a loop just to get the number of items. Something like scalar @{$config->{bids}{itemcode}}should do the trick. If you just look at the @{ } part, you'll notice it's the same way you'd get the number of elements from a "regular" array.
Some resources that may help you on your quest to learn more:
In reply to Re: References Looping
by VSarkiss
in thread References Looping
by CodeJunkie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |