Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have some code right now that censors the $topic like so
to turn any string that matches in $topic into <censored> and it works GREEEEEEEEEEEAT as tony the tiger says..for (@badwords) { $topic =~ s/$_/<censored>/g }
a week ago, someone came to me and said words like "ass" were getting drop kicked because of the word "class" and it would turn out as cl<censored>.
So, is there anyway that I can continue to look for matches in $topic that match with any word in @badword but if the word (whole word seperated by spaces) matches to ignore the whole thing and not censor that word at all but continue checking the rest of the words. does that make sence?
heres a better example, heres what happens now
for the example, lets say @badwords consists of "BARNEY GOOB CHICKEN"
if i try to set the topic to: "I LOVE BARNEY AND CHICKEN AND GOOBERS"
that code I have now will change it to:
"I LOVE <censored> AND <censored> and <censored>ERS"
Now lets say that @exceptions contains "GOOBERS", I would *LIKE* to have $topic turn into this instead: "I LOVE <censored> AND <censored> and GOOBERS"
Is that possible? I sure would apperciate the help, thanks! (by the way, everything is in lowercase and $topic is tr/[A-Z]/[a-z]/'ed)
UPDATE Masem lts', gts', CODE and Ps added for readability.
|
|---|