3 # Local 'autoqsl' module for DXSpider
5 # Copyright (c) 2003 Dirk Koopman G1TLH
17 use vars qw($qslfn $dbm);
21 localdata_mv("$qslfn.v1");
26 my $ufn = localdata("$qslfn.v1");
28 Prefix::load() unless Prefix::loaded();
35 dbg("Storable appears to be missing");
36 dbg("In order to use the QSL feature you must");
37 dbg("load Storable from CPAN");
40 import Storable qw(nfreeze freeze thaw);
43 $dbm = tie (%u, 'DB_File', $ufn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)";
45 $dbm = tie (%u, 'DB_File', $ufn, O_RDONLY, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)";
57 my ($pkg, $call) = @_;
58 return bless [uc $call, []], $pkg;
61 # called $self->update(comment, time, spotter)
62 # $self has the callsign as the first argument in an array of array references
63 # the format of each entry is [manager, times found, last time, last reporter]
73 foreach my $man (split /\b/, uc $line) {
76 if (is_callsign($man)) {
77 my @pre = Prefix::extract($man);
78 $tok = $man if @pre && $pre[0] ne 'Q';
79 } elsif ($man =~ /^BUR/) {
81 } elsif ($man eq 'HC' || $man =~ /^HOM/ || $man =~ /^DIR/) {
83 } elsif ($man =~ /^QRZ/) {
87 my ($r) = grep {$_->[0] eq $tok} @{$self->[1]};
96 $r = [$tok, 1, $t, $by];
97 unshift @{$self->[1]}, $r;
102 $self->put if $changed;
107 return undef unless $dbm;
111 my $r = $dbm->get($key, $value);
120 my $key = $self->[0];
121 my $value = nfreeze($self);
122 $dbm->put($key, $value);