my $alt = join '|', reverse sort <$matches_fh>; my $re = qr{(?x: ^ > ( $alt ) )}; my %count; /$re/ && ++$count{$1} while <$fasta_fh>;