Hey, procmail gurus

Kevin D. Clark kevin_d_clark at comcast.net
Tue Mar 27 17:30:39 EDT 2007


Bill Freeman writes:

> I have found that, usually, when a list posting has generated 10 or 20
> replies, I'm no longer interested in the follow-ups.  Can procmail count
> messages with the smae subject line (preferably ignore the depth of
> "Re:") and discard or divert additional messages once the count has
> been reached?  (There would be obvious refinements, such as being
> able to declare a thread interesting, letting it evade the count, but
> that's for later.)


How about this recipe?  (two, actually)
(not entirely tested...)


:0 f
* H ?? ^gnhlug
| perl -MEmail::Simple -MDB_File \
    -e '
         { local $/; $raw=<>; }  # slurp!

          my $email = Email::Simple->new($raw);

          $subject = $email->header("Subject");

          # setup db
          tie(%subjects_seen_counter, "DB_File", 
              "subjects_seen_counter")
             || die "tie problem: $!"; 
          $subjects_seen_counter{$subject}++;

          # if we have seen the subject 9 times, produce 9 asterisks...
          $email->header_set("X-Number-Responses-Seen", 
                             "*" x $subjects_seen_counter{$subject});
          untie(%subjects_seen_counter)
             || die "untie problem: $!";

          print $email->as_string;' 


# Bill wants to delete mail that has >15 responses
:0w:
* ^X-Number-Responses-Seen: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
/dev/null


Modify to suit taste.  Caveat programmer.  YMMV.  May cause blindness
and/or sudden omnipotence.  Not available in stores!  Do not taunt
Happy Fun Ball!

Just another Perl hacker,

--kevin

PS   This was a fun hack, although I gotta tell you, I'd rather just
     let my feature-rich mail client take care of this for me.

-- 
GnuPG ID: B280F24E              Never could stand that dog.
alumni.unh.edu!kdc                   -- Tom Waits


More information about the gnhlug-discuss mailing list