use Bio::Index::Fasta; my $idx = new Bio::Index::Fasta(-filename => 'seqs.idx', -write_flag => 1); $idx->id_parser(\&myidparser); $idx->make_index($seqfile); my @idlist = qw(456-3210 4670-5490); my @seqlist; for my $id ( @idlist ) { if( my $seq = $idx->get_Seq_by_acc($id) ) { push @seqlist, $seq; } } # define your own ID parser if you wanted to strip out # the gb| part of the id # alternatively don't do this and make sure the IDs # you input exactly match the IDs of the sequences sub myidparser { if( $_[0] =~ /^>\s*gb\|(\S+)/ ) { return $1; } elsif ($_[0] =~ /^>\s*(\S+)/) { return $1; } else { return; } }