in reply to Faster way to do this?
my $string = 'IIIIIIIIIIIMMMMMMMMMMMMOOOOOOOOOOOOMMMMMMMMMIIIIIIIII'; my $count = () = $string =~ /M/g; print $count; [download]
You can also use the tr operator.