Thing is, some of the words you're going to want to block if they're exact matches, and others if a word starts with them, and others still of a word contains them anywhere. What you really need is a series of regexes and perhaps a scoring system:
use strict; use warnings; my @ban = ( ['bleep\w*', 1], ['bloop\w*', 1], ['blark\w*', 2], ['blank', 1], ); my $text = join '', <DATA>; print check($text); sub check { my ($score, $word) = 0; $_ = lc($_[0]); s/\W+/ /g; for $word (@ban) { $score += m/\b$word->[0]\b/ * $word->[1]; } return $score; } __DATA__ Bleeping blooper! Blark you! Blank!
You will probably also want to replace any bad words with substitutes (maybe CENSORED) if the score is more than 0 but less than whatever your cut-off is, but I'll leave that part up to you.

My advice, however (as someone who used WWWBoard for years and was constantly trying to devise a system to stop spammers) is to forget trying to solve a problem that's impossible to solve. Instead of blocking posts based on their contents, just add a visual verification system that requires people to type in a code they see in a graphic. So long as the source graphics are your own, and not from some popular system that spammers have already cracked, you should end up reasonably spam-free. Just give people a cookie after the first verification that allows them to post for a few hours without further verifications, and add a system to block bots that try to brute force your verification. This way regular users won't be inconvenienced much, and spam bots won't be able to post at all.

Of course, there may be a few real people who post obscene things, so you'll still want to replace bad words with CENSORED.


In reply to Re: Including File in array by TedPride
in thread Including File in array by hmag

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.