use Bio::SearchIO. my $fh; open($fh, "fasta34 query.pep db |"); my $in = Bio::SearchIO->new(-format => 'fasta', -fh => $fh); while( my $r = $in->next_result ) { while( my $hit = $r->next_hit ) { while( my $hsp = $hit->next_hsp ) { } } }