in reply to Faster way to do this?
$string='IIIIIIIIIIIMMMMMMMMMMMMOOOOOOOOOOOOMMMMMMMMMIIIIIIIII'; print $count=$string=~s/M/M/g; [download]