while (<$in>) { my $locus =~ /LOCUS\s*(\w+)/; s/\^\^/>$locus\n^^\n/g; print $out $_; }