- Code: Select all
while ($seq =~ /M+/g) {
print "From ",length($`)," to ",length($`)+length($&),"\n";
}
Gives slightly different results to yours - but I think your sample answer applies to different data as the first M is at the 6th position not the 7th as per your sample answer.
I get
- Code: Select all
From 5 to 16
From 32 to 44
From 45 to 46
From 51 to 60
From 74 to 87
From 90 to 95
From 96 to 102
From 117 to 128
etc
which is counting the first character as position number 0 and is giving the first in each group and the first outside each group. I suggest adding / subtracting 1 if you want to tune this behaviour.
--
Graham