Click to See Complete Forum and Search --> : Perl Question: Guestbook


Diz
09-23-2002, 11:30 AM
I was wondering if there is a way to add a bad word filter to eliminate people from posting vulgar language in a guestbook. What would the perl code be to do this. Thanks.

Grizzly
09-23-2002, 01:39 PM
I would probably build a new line delimited text file of words I deemed as "bad". I would then have the Perl script do the following:

1) Open & Read badwordFile
2) Build the bad words into a data structure (most likely an array)
3) itterate through the bad words. For each bad word, perform a regular expression match against the user-submitted guestBook entry, and replace it with "****".

Ex:

$string =~ s/badword/******/gi;


Something along those lines would be fairly easy to program and should work out fairly well for you.

Diz
09-24-2002, 09:53 AM
Thanks Griz