in reply to incrementing hash values
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.
|
|---|