in reply to Replace ID names from FILE1 to FILE2

From you description, the only "sync" criteria betwen the files seems to be the sequence.

Based on that, this should work (untested):

#!/usr/bin/perl use strict; use warnings; open my $dnaseq, '<', "FILE2.TXT" or die "Can't open FILE2(Sequences): + $!\n"; open my $namesfile, '<', "FILE1.TXT" or die "Can't open NAMES: FILE1: +$!\n"; while (my $name = <$namesfile>) { chomp $name; <$dnaseq>; # Throw away "BARmmm;size=xxx" record chomp(my $seq = <$dnaseq>) ; # Should check if we actually have a $seq here.... print "$name\n$seq\n"; } close $dnaseq; close $namesfile; # Should check if there are left over records in $dnaseq....

        What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
              -Larry Wall, 1992