use strict; use Bio::DB::Fasta; my $db = new Bio::DB::Fasta( "Library.fa" ) # this should be the bigger file or die "Failed to create Fasta DB object on Library.fa\n"; open( IDLIST, "Name.fa" ); # this is the list of ID strings while ( ) { my ($id) = (/^>(\S+)/); # capture the id string (without the initial ">") print ">$id\n", $db->seq( $id ), "\n"; }