in reply to Print the data following few specific lines in perl

A simpler and more robust approach is to let BioPerl handle that for you since it can understand the FastA format quite well and that it has good measures for IO operations, check Perl and Bioinformatics for a general introductory.

The code below reads into two hashes the provided sequences depending on whether they have pair info or not at the descriptor portion of their corresponding records, writing each one of these hashes into a file is left as an exercise for the OP..

use strict; use warnings; use Bio::SeqIO; my $file = "FastA.txt"; my $seq_obj = Bio::SeqIO->new(-file =>"<$file",-format=>'fasta',); my %seqPair; my %seq_NoPair; while(my $seq = $seq_obj->next_seq){ #iterate through records if($seq->desc =~ /.*?pair.*?/i){ $seqPair{$seq->id}=$seq->seq; }else{ $seq_NoPair{$seq->id}=$seq->seq; } } #use Data::Dump qw(pp); #print pp \%seqPair; #print pp \%seq_NoPair;


Excellence is an Endeavor of Persistence. A Year-Old Monk :D .