http://qs321.pair.com?node_id=462548


in reply to can you please fix the error

Not the most efficient method, but anyway, assuming that both your files contain one word per line, the mistake is here:

WORD: foreach $word (@data) { STOP: foreach $stop (@stopwords) { next WORD if $word eq $stop; # <--- } push(@lessWords, $word); }

Whenever a stopword matches, you should exite the outer loop.

Consider using a hash instead.

my %stops = map {$_,undef} @stopwords; for my $word (@data) { next if exists $stops{$word}; push(@lessWords, $word); }