Regexes aren't good for counting anything. (Yes, there are regex hacks that count things, but we leave that aside for a moment...)
You should traverse your lines char by char and then check (perhaps with a regex, or with a hash lookup) if the char is interesting to you. | [reply] |
You want something like this:
my %hist;
while(<$fh>){
++$hist{ $_ } for split //;
}
for(sort{ $hist{ $b } <=> $hist{ $a } } keys %hist){
print "'$_' => $hist{ $_ }\n";
}
but you need to filter out the chars you don't want. | [reply] [d/l] |