Perl Question: Guestbook

Sharky Forums


Results 1 to 3 of 3

Thread: Perl Question: Guestbook

  1. #1
    Catfish Diz's Avatar
    Join Date
    Oct 2001
    Location
    Philly, PA USA
    Posts
    220

    Perl Question: Guestbook

    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.
    What you got?

  2. #2
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077
    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:
    Code:
    $string =~ s/badword/******/gi;
    Something along those lines would be fairly easy to program and should work out fairly well for you.

  3. #3
    Catfish Diz's Avatar
    Join Date
    Oct 2001
    Location
    Philly, PA USA
    Posts
    220
    Thanks Griz
    What you got?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •