in reply to Can you write a faster code to perform this task?
You'll have to Benchmark it yourself to see if it's any faster, but maybe:
c:\@Work\Perl\monks>perl -wMstrict -le "$_ = 'iiiiiiiiMMMMMMMMMMMooooooooooooMMMMMMMMMMiiiiiMMMMMMMMoooo'; my $count =()= $_ =~ m{ M+ }xmsg; print $count; " 3
|
|---|