- or download this
use strict;
use warnings;
...
eval "\$count = \$string =~ tr/$a//";
print "$count\n";
}
- or download this
$count = $string =~ s/$a//g;
- or download this
my %count;
$count{$_}++ foreach split //, $string;
print "$count{$_}\n" foreach (@letters);