in reply to Print A Sequence with Start codon and different Stop Codon

#!/usr/bin/perl # http://perlmonks.org/?node_id=1146191 use strict; use warnings; my $sequence = 'AATGGTTTCTCCCATCTCTCCATCGGCATAAAAATACAGAATGATCTAACGAA' +; $sequence =~ /(ATG.*?(?:TAG|TAA|TGA))(??{print "$1\n"})/;

which prints:

ATGGTTTCTCCCATCTCTCCATCGGCATAA ATGGTTTCTCCCATCTCTCCATCGGCATAAAAATACAGAATGA ATGGTTTCTCCCATCTCTCCATCGGCATAAAAATACAGAATGATCTAA ATGATCTAA

Replies are listed 'Best First'.
Re^2: Print A Sequence with Start codon and different Stop Codon
by PerlKc (Novice) on Oct 28, 2015 at 01:44 UTC

    Output is right on dot, but couldn't get it when I used the code you posted.

Re^2: Print A Sequence with Start codon and different Stop Codon
by PerlKc (Novice) on Oct 28, 2015 at 01:50 UTC

    THanks Bunch, It Works. YAYYYYYYYY! I have a quick question what does the ?? before the print command does?

      See "(??{ code })" in perldoc perlre

        should that be "(?{ code })" instead of "(??{ code })" ?