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
In reply to Re: This should be easy: counting letters in a string
by prasadbabu
in thread This should be easy: counting letters in a string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |