in reply to loop issue...

Well, here you check whether this particular file is one of the four you want:
for my $f(@files){ if($f=~ m%^(\d*)(HU.fa|HD.fa|Ltvec_small.FA|_fasta)$%) {
But on the very next line, you decide to process all of them:
my ($fa, $hu, $hd, $lt)= ($1."_fasta", $1."HU.fa", $1."HD.fa", $1."Ltv +ec_small.FA");
So each time your code hits HU.fa, it'll process all the files. Then when it hits HD.fa, it'll process them all again. Same for the other two. That's why you see the output 4x.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.