2 # class to handle all dupes in the system
4 # each dupe entry goes into a tied hash file
6 # the only thing this class really does is provide a
7 # mechanism for storing and checking dups
16 use vars qw{$lasttime $dbm %d $default $fn};
18 $default = 48*24*60*60;
20 $fn = "$main::data/dupefile";
24 $dbm = tie (%d, 'DB_File', $fn);
27 dbg("Dupefile $fn corrupted, removing...");
29 $dbm = tie (%d, 'DB_File', $fn) or confess "can't open dupe file: $fn ($!)";
30 confess "cannot open $fn $!" unless $dbm;
57 my $t = shift || $main::systime + $default;
70 if ($main::systime - $lasttime >= 3600) {
72 while (($k, $v) = each %d) {
73 push @del, $k if $main::systime >= $v;
75 delete $d{$_} for @del;
76 $lasttime = $main::systime;
84 while (($k, $v) = each %d) {
85 push @out, $k, $v if !$start || $k =~ /^$start/;
96 $regex =~ s/[\^\$\@\%]//g;
97 $regex = ".*$regex" if $regex;
98 $regex = "^$let" . $regex;
100 for (sort { $d{$a} <=> $d{$b} } grep { m{$regex}i } keys %d) {
101 my ($dum, $key) = unpack "a1a*", $_;
102 push @out, "$key = " . cldatetime($d{$_} - $dupage) . " expires " . cldatetime($d{$_});