in reply to Re: Storing unique values
in thread Storing unique values
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.
|
|---|