Why take the trouble of making the hash increment inside the pattern instead of in the loop? That kind of cheats the loop expression of its task. :-)
my %counts; $counts{$1}++ while $string =~ /([^,]+)/g;
lodin
In reply to Re^2: how to count the no of repeats in a string
by lodin
in thread how to count the no of repeats in a string
by koleti
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |