in reply to explanation of code pls

The condition in the while loop will be true for as many times as there are substrings contained in $seg that begin with "ATG", followed by zero or more sets of any three characters, and end with any of "TGA", "TAG" or "TAA". The "*?" bit after the "(...)" indicates that this pattern (any three characters) should be "non-greedy" -- i.e. match as few times as possible before looking for the "(?=TAA|TAG|TGA)".

For each iteration where this test succeeds, the length of the string that follows the match is assigned to $start -- because the final "TAA or TAG or TGA" part of the match is used within "(?= )", it gets counted/included as part of the string that follows the match. (Look up the $' variable in perlvar, and the "(?=pattern)" construct in perlre.)