my @excluded = qw( a did encountered process ); # tailor as appropriate for my $line (@lines) { local $"= '.*?'; #" # break the line into an array of words minus exclusions my @words = grep{ !(1+index($excluded,$_)); } $line =~ m/\b\w+\b/g # replace each line with a fuzzy matching compiled regex $line = qr"@word"o; }