in reply to This should be easy: counting letters in a string
As inman suggested you can make use of eval. If you dont have any peroformance issue, you can use s operator.
@letters = qw(A B C D E F); $string = "AFTYUBEWTWECRTUTYIYTDDDDRYJURTHJTREEEEEFGSDFF"; for $a (@letters) { $count = $string =~ s/$a//g; print "$count\n"; } output: 1 1 1 5 7 4
Prasad
|
|---|