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