http://www.perlmonks.org?node_id=1013575


in reply to Two simple code style advice questions

1) When using a hash to store counts, I prefer just relying on the fact that a key springs into existence upon $hash{key}++. After all, I'm a lazy Perl programmer! Assuming your code needs them all initialized, I'd slightly prefer map I suppose, because it is one line (I don't like putting two statements on a single line, as some are suggesting for the second method).

2) The first version is kind of wacky. I would use the second.