3 # Local 'autoqsl' module for DXSpider
5 # Copyright (c) 2003 Dirk Koopman G1TLH
17 use vars qw($VERSION $BRANCH);
18 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
19 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
20 $main::build += $VERSION;
21 $main::branch += $BRANCH;
23 use vars qw($qslfn $dbm);
30 my $ufn = "$main::root/data/$qslfn.v1";
32 Prefix::load() unless Prefix::loaded();
39 dbg("Storable appears to be missing");
40 dbg("In order to use the QSL feature you must");
41 dbg("load Storable from CPAN");
44 import Storable qw(nfreeze freeze thaw);
47 $dbm = tie (%u, 'DB_File', $ufn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)";
49 $dbm = tie (%u, 'DB_File', $ufn, O_RDONLY, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)";
61 my ($pkg, $call) = @_;
62 return bless [uc $call, []], $pkg;
65 # the format of each entry is [manager, times found, last time]
75 foreach my $man (split /\b/, uc $line) {
78 if (is_callsign($man)) {
79 my @pre = Prefix::extract($man);
80 $tok = $man if @pre && $pre[0] ne 'Q';
81 } elsif ($man =~ /^BUR/) {
83 } elsif ($man eq 'HC' || $man =~ /^HOM/ || $man =~ /^DIR/) {
85 } elsif ($man =~ /^QRZ/) {
89 my ($r) = grep {$_->[0] eq $tok} @{$self->[1]};
98 $r = [$tok, 1, $t, $by];
99 unshift @{$self->[1]}, $r;
104 $self->put if $changed;
109 return undef unless $dbm;
113 my $r = $dbm->get($key, $value);
122 my $key = $self->[0];
123 my $value = nfreeze($self);
124 $dbm->put($key, $value);