Hi Monks. I have a badwords routine that checks a text file of bad words (1 per line) and then sends an email to the admin of a suspect word is posted. My question is how to get the suspect word to print in the email. This should be simple but I'm missing something. I've commented out the lines that make the badword print to the screen and I can't get it to print in the email. People write and ask why the spam filter was triggered and I have no way to know. Thanks.
sub filter_bad_words_suspect { $bad_words_file = "/bad-words-suspect.txt"; $badword_found = 0; open(BADWORDS,"$bad_words_file") || die "*** Could not open bad wo +rds list.\n"; @badwords = <BADWORDS>; close(BADWORDS); foreach $badword (@badwords) { # Strip any extra CR/LF's $badword =~ s/\n//g; $badword =~ s/\r//g; if (($description =~ /$badword/i) || ($email =~ /$badword/i) +|| ($title =~ /$badword/i) || ($contact =~ /$badword/i) || ($organiza +tion =~ /$badword/i)) { $badword_found = 1; # If a bad word is found, highlight all occurances of it #$contact =~ s/($badword)/<B>$1<\/B>/ig; #$email =~ s/($badword)/<B>$1<\/B>/ig; #$title =~ s/($badword)/<B>$1<\/B>/ig; #$description =~ s/($badword)/<B>$1<\/B>/ig; #$organization =~ s/($badword)/<B>$1<\/B>/ig; } # end if (($name =~ /$badword/i) || ($email =~ /$badword/i). +.. } # end foreach $badword (@badwords) &error2(bad_words) if ($badword_found == 1); return; } # end filter_bad_words subroutine sub error2 { require "all-common.sub" || die "Error loading all-common.sub"; $error = $_[0]; $admin_email = "info\@123.com"; open (MAIL, "|$mailprog $admin_email") || die "Can't open +$mailprog!\n"; print MAIL "From: Test Server <admin@123.com>\n"; print MAIL "To: $admin_email\n"; print MAIL "Subject: Error: Suspect Words\n"; print MAIL "Content-type: text/plain\n"; print MAIL "The spam filter was triggered.\n\n"; print MAIL "Name: $name\n"; print MAIL "Username: $username\n"; print MAIL "Email: $email\n"; print MAIL "IP: $IP\n"; print MAIL "Badword: $badword\n"; close (MAIL); return; }

In reply to Badwords Routine by htmanning

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.