I would have organized the code slightly differently, factoring each of the pattern elements into a separate qr// regex object and combining them together (inside a capture group) in the final m// match:
Separate qr// definitions ease maintenance and, if variable names be wisely chosen, are self-commenting. If possible, I only use capture groups in the final m// match due to the confusion that trying to count nested capture groups can produce.c:\@Work\Perl\monks>perl -wMstrict -le "my $codon = qr{ [ACGT]{3} }xms; my $start = qr{ ATG }xms; my $end = qr{ TAG | TAA | TGA }xms; ;; my $seq = 'AATGGTTTCTCCCATCTCTCCATCGGCATAAAAATACAGAATGATCTAACGAA'; ;; print qq{'$1'} while $seq =~ m{ ($start $codon*? $end) }xmsg; " 'ATGGTTTCTCCCATCTCTCCATCGGCATAA' 'ATGATCTAA'
Give a man a fish: <%-{-{-{-<
In reply to Re^3: Regular expressions
by AnomalousMonk
in thread Regular expressions
by lairel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |