Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
#!/usr/bin/perl
#
#      run sa-learn on STDIN ... easy to use with .qmail files:
#
#  .qmail-spamtrap:  
#      | bayes_fixup.pl | learn_spam --spam --username=alias | cat - > /dev/null
#  .qmail-qqqhamreport:
#      | bayes_fixup.pl | learn_spam --ham --username=alias | cat - > /dev/null
#
#  43/16/2005 -- cgg007 at yahoo.com
#

use strict;

sub learn {
  my $message = shift;
  my $pipe = shift;
  open LEARN, $pipe;
  print LEARN $message;
  close LEARN;
}

my $learn_cmd =  "| bayes_fixup.pl | sa-learn " . join(" ",@ARGV);
my $count = 0;
my $message = '';

while (<STDIN>) {

  /^From/ and do {
    if ($count) {
      learn($message,$learn_cmd) if $count;
      $message = '';
    }
    $count++;
  };

  $message .= $_;

}

learn($message,$learn_cmd);

...