foreach my $keyLOOK(keys %UnNum){ foreach my $word(@midWords){ if $word == $keyLOOK { $UnNum{$keyLOOK}++; } } }