You're viewing a comment by Peter Krumins and its responses.

May 22, 2013, 19:37

Hi Stuart,

Here's how you make one of your spam_keyword entries be "other-than-contact"

use warnings;
use strict;

my @files = <msg*.txt>;
open my $out, '>', 'spam-emails.txt' or die 'failed opening spam-emails.txt: ' . $!;

for my $file (@files) {
  my $contents = do {
    open my $fh, '<', $file or die 'error opening ' . $filename . ': ' . $!;
    local $/; <$fh>
  $_ = $contents;
  unless (/ {
    print $out qq/$file\n/;
  if (/spam_keyword_1/ || /spam_keyword_2/ || /spam_keyword_3/) {
    print $out qq/$file\n/;

Make sure that is in the email when doing this.

What the "unless" line does is it checks if is NOT the email, and if it is NOT, then print it to spam file, and proceed the next email. ("unless (x) { ... }" means "if (!x) { ... }" in Perl).

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "server_303": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.