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.
Printable View
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.
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:
Something along those lines would be fairly easy to program and should work out fairly well for you.Code:$string =~ s/badword/******/gi;
Thanks Griz