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";
25 $dbm = tie (%d, 'DB_File', $fn);
26 confess "cannot open $fn $!" unless $dbm;
53 my $t = shift || $main::systime + $default;
66 if ($main::systime - $lasttime >= 3600) {
68 while (($k, $v) = each %d) {
69 push @del, $k if $main::systime >= $v;
71 delete $d{$_} for @del;
72 $lasttime = $main::systime;
80 while (($k, $v) = each %d) {
81 push @out, $k, $v if !$start || $k =~ /^$start/;
92 $regex =~ s/[\^\$\@\%]//g;
93 $regex = ".*$regex" if $regex;
94 $regex = "^$let" . $regex;
96 for (sort { $d{$a} <=> $d{$b} } grep { m{$regex}i } keys %d) {
97 my ($dum, $key) = unpack "a1a*", $_;
98 push @out, "$key = " . cldatetime($d{$_} - $dupage) . " expires " . cldatetime($d{$_});