No need to jump through hoops. Perl doesn't complain when increasing undefined variables, so this will do:if (exists($hash->{$cur})) { $hash->{$cur}++; } else { $hash->{$cur} = 1; }
It's the accept practice for this case, in fact, so it should be done this way as well.$hash->{$cur}++;
Makeshifts last the longest.
In reply to Re^2: Storing unique values
by Aristotle
in thread Storing unique values
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |