in reply to Count not working

If count is never defined, it is undef and hence equal to 0 in numeric context. If you are just trying to accumulate the number of times you encounter a certain value of comp, perhaps you mean:

foreach (@COMPANIES) { $sum{$_->{comp}}++; }

Note that since Perl automatically stringifies alphanumeric hash keys, you don't need to include quotes in this context.

Replies are listed 'Best First'.
Re^2: Count not working
by molson (Acolyte) on Jul 14, 2010 at 18:46 UTC
    That worked, thanks! And thanks for the tip about the quotes.