If $value can be undefined, your check will be testing for the wrong thing. Use exists instead of defined.
But that's still klunky. Instead try
push @{ $hash{ $key } }, $value;
Now the value for each key will be an array reference containing all the different values.
Makeshifts last the longest.
In reply to Re: incrementing hash values
by Aristotle
in thread incrementing hash values
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |