while (my $line = <$fh2>) { ++$found{$_} for grep { !$stopwords->{$_} } split /\s+/, lc $line; } print $fh $_, "\t\t", $found{$_}, $/ for sort keys %found;