open( LIST, "mystopwords.txt" ) or die "$!"; my @stopwords = ; # assuming one stop word per line close LIST; chomp @stopwords; my $stopregex = join '|', @stopwords; # ... now, when you go to delete stopwords from $_, # it goes like this: s/\b(?:$stopregex)\b//g;