open (FILE1, ">10.txt"); open (FILE2, ">20.txt"); open (FILE3, ">30.txt"); my @files = glob('Data/*.fa'); my %hash = &readFile(); foreach my $f(@files){ open FILE, $f or die "Cannot open : $!\n"; while (my $line = ){ chomp $line; #print "$line\n"; if($line =~ /^>/){ my @head = split (/ /, $line); my $name = substr($line, 1); foreach my $key(keys %hash){ if($key eq $name){ if($hash{$key} == 10){ select FILE1; } if($hash{$key} == 20){ select FILE2; } if($hash{$key} == 30){ select FILE3; } } } } } }