You've set yourself a large task and one that will require a large dictionary of forbidden words. First, I hope I'm clear on the first 3 lines of your logic: the csv file will contain the list of verboten words and $d will (sequentially) hold individual "hotwords" for processing (and you'd be better off to call that $hotwords or something clearer than a single character variable name.)

But where's the user input? Ah, need another var, say, $in_msg.

And then you want to compare the input with the forbidden words... so you're going to walk the text, with another split (of $in_msg to, say, @suspect and then compare each of your $hotwords with each word in @suspect? (caveat: if you use eq rather than a regex you'll need all the possible VaRIAtions OF cAsE. On the other hand, if you go with a regex (case insensitive, one presumes), please share the construct that matches all your possible prohibitions as :-) I'm not familiar with that one.

And now you have to decide what to do about the offensive words. Are you going to simply replace them with something that's less offensive -- say "XXXX?" Or are you going to send the whole post to the bitbucket? Or someting else? More thought required here.

Also, suppose "free p0rn!" is in your hotwords file but the poster writes "free porn." Now we're dealing not only with enlarging your hotwords dictionary; we may also be having to deal with parsing natural language. And that's hard: suppose the poster is writing to condemn "free porn" (or any other kinds). Do you want that post banned?

Or, just one more before the examples get tedious: Suppose your posted writes "Free Guppies" or some other captive group? What now?

Perhaps you've thought this through before; but if not, it may well be worth your time and trouble to reconsider your distaste for using a module.


In reply to Re: Filtering SPAM hot words from Message Post by ww
in thread Filtering SPAM hot words from Message Post 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.