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";
22 use vars qw($VERSION $BRANCH);
24 main::mkver($VERSION = q$Revision$);
28 $dbm = tie (%d, 'DB_File', $fn);
31 dbg("Dupefile $fn corrupted, removing...");
33 $dbm = tie (%d, 'DB_File', $fn) or confess "can't open dupe file: $fn ($!)";
34 confess "cannot open $fn $!" unless $dbm;
61 $t = $main::systime + $default unless $t;
74 if ($main::systime - $lasttime >= 3600) {
75 while (($k, $v) = each %d) {
76 delete $d{$k} if $main::systime >= $v;
78 $lasttime = $main::systime;
86 while (($k, $v) = each %d) {
87 push @out, $k, $v if !$start || $k =~ /^$start/;
98 $regex =~ s/[\^\$\@\%]//g;
99 $regex = ".*$regex" if $regex;
100 $regex = "^$let" . $regex;
102 for (sort { $d{$a} <=> $d{$b} } grep { m{$regex}i } keys %d) {
103 my ($dum, $key) = unpack "a1a*", $_;
104 push @out, "$key = " . cldatetime($d{$_} - $dupage);