$str = "aaabbbccc";
print ($str =~ y/a/a/);
じゃだめなのか?