how does $dna =~ / (\w\w\w)*? TGA /gx differ logically from $s =~ / (f)*? C /gx
The important difference here is the length of $1.
After the first match (A is where the matching started, B denotes the position of the capture group)
XXXxxxTGAxxTGAxxxxTGAxx
^ ^
| |
A B
the matching starts at B + 1. Zero times \w\w\w doesn't match here, we have xxTGAx, so the engine tries longer and longer strings, until it finds the TGA:
XXXxxxTGAxxTGAxxxxTGAxx
^ ^
| |
A B
The next search will start at B + 1 again, and fail on xx.
But, with the capture group of length 1, you always match the nearest group, because the (f)*? tries longer and longer strings. Maybe what's confusing here is that expanding the group by one character is similar to the engine advancing the starting position after a match failure?
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,