On Wed, 23 Dec 1998, Chris Garrigues wrote:
>
> Two problems Russ.
>
> 1) That URL doesn't get you to "eliminate-dups" since index.html is the page
> that gives you a list of mirrors.
>
> 2) A minor bin in eliminate-dups: you have to create the .older file by hand.
>
> Attached, you'll find the version of your script that I'm currently using.
And attached you'll find mine. It is based on Russ' original but uses
dbm hash file(s) instead of a text file.
Regards
Peter
----------
Peter Samuel [EMAIL PROTECTED]
Technical Consultant or at present:
Uniq Professional Services [EMAIL PROTECTED]
Phone: +61 2 9206 3410 Fax: +61 2 9281 1301
"If you kill all your unhappy customers, you'll only have happy ones left"
#! /pkgs/bin/perl
# Original by Russ Nelson. This version by Peter Samuel.
# This version uses a dbm file instead of a text file.
# Call from a .qmail file as follows:
# |bin/eliminate-dups Mailbox
$hashname = shift;
$hashname = ".maildups" unless $hashname;
use MD5;
$md5 = new MD5;
$loose = 1; # loose matching if set.
while(<>) {
last if /^$/;
next if $ignore_continue && /^\s/;
$ignore_continue = 0;
if (/^received:/i) {
$ignore_continue = 1;
next;
}
if (!$loose) {
$headers .= $_;
next;
}
if ($keep_continue && /^\s/) {
$headers .= $_;
next;
}
$keep_continue = 0;
if (m/^(from|message-id|date):/i) {
$headers .= $_;
$keep_continue = 1;
next;
}
next;
}
$md5->add($headers);
$md5->addfile(STDIN);
$hash = $md5->hexdigest;
dbmopen(%HASH, "$hashname", 0644);
if (defined $HASH{$hash})
{
# Message is a duplicate - goodbye
dbmclose(%HASH);
exit(99);
}
# Message is new, add its checksum to the list of seen messages
$now = time;
$HASH{$hash} = $now;
# Remove old entries
$ttl = 3600 * 24 * 7; # time to live - 7 days in seconds
for (keys %HASH)
{
delete $HASH{$_} if (($now - $HASH{$_}) > $ttl);
}
dbmclose(%HASH);