You can't do that without an explicit loop. It's the nature of hash assignments. The right-hand list is only evaluated once, with competing keys successively overwriting each other on assignment, so it's not possible to do such a calculation.
As an aside, Perl6 hyperops would allow this. The closest Perl5 gets is
++$_ for @count{ @a };
Makeshifts last the longest.
In reply to Re: How can I populate a hash?
by Aristotle
in thread How can I populate a hash?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |