Ok.. heres a toughie. I have one scaler and two arrays, the sclaer called $topic (containing 2 - 40 elements within the it, I also have @topic with the same data), @badwords (which contains words we want to censor because they're potty mouth) and @exceptions (which contains words that are allowed to be used).

I have some code right now that censors the $topic like so

for (@badwords) { $topic =~ s/$_/<censored>/g }
to turn any string that matches in $topic into <censored> and it works GREEEEEEEEEEEAT as tony the tiger says..

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.


In reply to Defenetly a complicated perl recipie with 2 arrays, 1 scaler and some special matching by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.