projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
correct convert-users-v3-to-v4.pl
[spider.git]
/
perl
/
QSL.pm
diff --git
a/perl/QSL.pm
b/perl/QSL.pm
index 1738ed6ed67831072d1a97754717a22b100898e0..67bffc3252004e44631fd3efb3d017e94ef7f16c 100644
(file)
--- a/
perl/QSL.pm
+++ b/
perl/QSL.pm
@@
-13,32
+13,24
@@
use DXUtil;
use DB_File;
use DXDebug;
use Prefix;
use DB_File;
use DXDebug;
use Prefix;
+use JSON;
-use vars qw($qslfn $dbm);
+use vars qw($qslfn $dbm
$maxentries
);
$qslfn = 'qsl';
$dbm = undef;
$qslfn = 'qsl';
$dbm = undef;
+$maxentries = 50;
-localdata_mv("$qslfn.v
1
");
+localdata_mv("$qslfn.v
2
");
sub init
{
my $mode = shift;
sub init
{
my $mode = shift;
- my $ufn = localdata("$qslfn.v
1
");
+ my $ufn = localdata("$qslfn.v
2
");
Prefix::load() unless Prefix::loaded();
Prefix::load() unless Prefix::loaded();
- eval {
- require Storable;
- };
-
- if ($@) {
- dbg("Storable appears to be missing");
- dbg("In order to use the QSL feature you must");
- dbg("load Storable from CPAN");
- return undef;
- }
- import Storable qw(nfreeze freeze thaw);
my %u;
my %u;
+ undef $dbm;
if ($mode) {
$dbm = tie (%u, 'DB_File', $ufn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)";
} else {
if ($mode) {
$dbm = tie (%u, 'DB_File', $ufn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)";
} else {
@@
-58,6
+50,8
@@
sub new
return bless [uc $call, []], $pkg;
}
return bless [uc $call, []], $pkg;
}
+# called $self->update(comment, time, spotter)
+# $self has the callsign as the first argument in an array of array references
# the format of each entry is [manager, times found, last time, last reporter]
sub update
{
# the format of each entry is [manager, times found, last time, last reporter]
sub update
{
@@
-67,19
+61,24
@@
sub update
my $t = shift;
my $by = shift;
my $changed;
my $t = shift;
my $by = shift;
my $changed;
-
+
+ return unless length $line && $line =~ /\b(?:QSL|VIA)\b/i;
foreach my $man (split /\b/, uc $line) {
my $tok;
foreach my $man (split /\b/, uc $line) {
my $tok;
- if (is_callsign($man)) {
+ if (is_callsign($man)
&& !is_qra($man)
) {
my @pre = Prefix::extract($man);
$tok = $man if @pre && $pre[0] ne 'Q';
} elsif ($man =~ /^BUR/) {
$tok = 'BUREAU';
my @pre = Prefix::extract($man);
$tok = $man if @pre && $pre[0] ne 'Q';
} elsif ($man =~ /^BUR/) {
$tok = 'BUREAU';
+ } elsif ($man =~ /^LOTW/) {
+ $tok = 'LOTW';
} elsif ($man eq 'HC' || $man =~ /^HOM/ || $man =~ /^DIR/) {
$tok = 'HOME CALL';
} elsif ($man =~ /^QRZ/) {
$tok = 'QRZ.com';
} elsif ($man eq 'HC' || $man =~ /^HOM/ || $man =~ /^DIR/) {
$tok = 'HOME CALL';
} elsif ($man =~ /^QRZ/) {
$tok = 'QRZ.com';
+ } else {
+ next;
}
if ($tok) {
my ($r) = grep {$_->[0] eq $tok} @{$self->[1]};
}
if ($tok) {
my ($r) = grep {$_->[0] eq $tok} @{$self->[1]};
@@
-95,6
+94,8
@@
sub update
unshift @{$self->[1]}, $r;
$changed++;
}
unshift @{$self->[1]}, $r;
$changed++;
}
+ # prune the number of entries
+ pop @{$self->[1]} while (@{$self->[1]} > $maxentries);
}
}
$self->put if $changed;
}
}
$self->put if $changed;