in reply to Removing common words

But this doesn't remove the words. What's wrong?

Two things.

First, look closely at line 65

You are not adding to @words but overwriting it for each line of <IN>.

This is easy to fix, just use push like this:

push @words,split(/\W/, $_);

Second, look at your loop labelled OUTER.

You loop through the list of banned words, and for each banned word you check to see if it is equal to the candidate word. If not, you accept it into %count.

This means you even though a word might be on the banned list, you will accept it into %count many times before finally "rejecting" it.

The fix is simple. Replace lines 69 to 77 with

$count{$word}++ unless exists $banned{lc $word};