in reply to Counting within an array

It is very useful to note how, in the first response, the statement e.g. $$somehash{$somekey}++ will automagically create a new hash-element, with a value of 1, if such a key does not presently exist.

In fact, “incrementing an undef value” works in-general, producing a value of 1.   A delightful example of “DWIM = Do What I Mean.”

One tiny consideration if you happen to be reading strings from a file:   don’t forget to chomp.   Otherwise, the strings you read might contain invisible “newline” characters which can make for irritating annoyance-bugs.