A different approach might be to use the $/ variable ( see perlvar for details ) to read in each record and then test whether it has the 'pairs' field:
use warnings; use strict; { ## modify input record separator to read ## each FASTA record separately local $/ = '>'; ## test each record, printing out if it has ## pair field while (<DATA>){ print $_ if ($_ =~ /pair:\d+/); } } __DATA__ >CVSF43567.d1 bg|346280 CGTAGCTGATGCTGTGCTGTTGTGTCGGGGGGATATATATATATATATGGGGTCGTAGTCGTAGCGCTAG TATGCTAGCAGCGTAGATGCTGATCGATGCTGATGCTGATCGTAGTCGTAGGCTAGTGCGATCGTAGTCG TAGTCGATGCTGATGCGTAGCTGATGTGCTGCTGATGCTAGTCGTCGTAGCTGATGCATGCTGATCGTAG TGCTCGATGCTAGTCGTAGTCGTAGTCGTAGCGACTGATGCGATCGTAGTCGGATGCTAGCACGTAGCTG GCTCGATGCTGATGCTGAT >CVSF10000.x1 bg|356789 pair:789860 ATGCGTAGCTGATGTGCTGCTGATGCTAGTCGTCGTAGCTGATGCATGCTGATCGTAGTGCTCGATGCTA GTCGTAGTCGTAGTCGTAGCGACTGATGCGATCGTAGTCGGATGATGCTGACTGATGCTGATCTGTACGT CGTAGCTGATGCATGCGCTAGTAGCT >CVSF10000.y1 bg|356790 pair:789859 GCTAGTCGATGCTGATGCTGTAGCTAGCGTAGTCGTACGCGCGCGCGCGCGTTTTTTGTGACGTCGTAGT CCGTAGCTGATGCGATGCTAGTGCTGTGTCAGCTGATGTCGTGTGTAGCTGATGCTGATCGTTCGTGTGT CGATGCTGATGCTAGTCGTAGTGTAT
In this case I am simply testing for the presence of the 'pair' field using a regex (see perlre). Hope this helps!
In reply to Re: Print the data following few specific lines in perl
by BioLion
in thread Print the data following few specific lines in perl
by ad23
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |