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);
23 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
24 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
25 $main::build += $VERSION;
26 $main::branch += $BRANCH;
30 $dbm = tie (%d, 'DB_File', $fn) or confess "can't open dupe file: $fn ($!)";
50 return 1 if exists $d{$_[0]};
56 $t = $main::systime + $default unless $t;
69 if ($main::systime - $lasttime >= 3600) {
70 while (($k, $v) = each %d) {
71 delete $d{$k} if $main::systime >= $v;
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);