#!/usr/bin/perl
$seq ="CGGTTAATGGGAATACGCGGATAAGGCGAAATGCACCACGACGCCATAATTTGAAGGATG";
#            ^^^............^^^      ^^^..................^^^   ^^^

$cod="([ATGC]{3})";
$stop = "(TAG|TAA|TGA)";
$start = "ATG";
while ( $seq =~ /$start(($cod)$cod*?\2)$stop/g ) {
   print "$1\n";
}
