in reply to 'grouping' substrings?

Others seem to have interpreted this as "find all groups of one or more M's".

On the off chance that you actually meant 6 or more M's, try this modification of japhy's solution:

my $seq = "..."; my @groups; push @groups, [$-[0], $+[0]-1] while $seq =~ /M{6,}/g; print "$_->[0] to $_->[1]\n" for @groups;
(where the displayed positions are 0-based.)