## build a regular expression to match all the words in @ignore my $ignore = '(?:\b'. join('\b|\b', map quotemeta, @ignore). '\b)'; ## assuming @words contains the contents of the file s/$ignore// for map lc, @words;