From d384410d4d5d1031cabab44350b80f2a55fe808d Mon Sep 17 00:00:00 2001 From: minima Date: Wed, 12 Mar 2003 17:30:03 +0000 Subject: [PATCH] disable checking in Chain as default add prefix check for callsigns in QSL.pm --- perl/Chain.pm | 2 +- perl/Prefix.pm | 5 +++++ perl/QSL.pm | 44 ++++++++++++++++++++++++++++---------------- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/perl/Chain.pm b/perl/Chain.pm index c065d17a..60266c75 100644 --- a/perl/Chain.pm +++ b/perl/Chain.pm @@ -15,7 +15,7 @@ use constant OBJ => 2; use vars qw($docheck); -$docheck = 1; +$docheck = 0; sub _check { diff --git a/perl/Prefix.pm b/perl/Prefix.pm index b43d9160..91f7c5ce 100644 --- a/perl/Prefix.pm +++ b/perl/Prefix.pm @@ -85,6 +85,11 @@ sub load return $out; } +sub loaded +{ + return $db; +} + sub store { my ($k, $l); diff --git a/perl/QSL.pm b/perl/QSL.pm index 0de92688..4d3bd115 100644 --- a/perl/QSL.pm +++ b/perl/QSL.pm @@ -12,6 +12,7 @@ use DXVars; use DXUtil; use DB_File; use DXDebug; +use Prefix; use vars qw($VERSION $BRANCH); $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); @@ -28,6 +29,8 @@ sub init my $mode = shift; my $ufn = "$main::root/data/$qslfn.v1"; + Prefix::load() unless Prefix::loaded(); + eval { require Storable; }; @@ -67,29 +70,38 @@ sub update my $line = shift; my $t = shift; my $by = shift; + my $changed; + + foreach my $man (split /\b/, uc $line) { + my $tok; - my @tok = map {/^(?:HC|BUR|QRZ|HOME)/ || is_callsign($_) ? $_ : ()} split(/\b/, uc $line); - foreach my $man (@tok) { - if ($man =~ /^BUR/) { - $man = 'BUREAU'; + if (is_callsign($man)) { + my @pre = Prefix::extract($man); + $tok = $man if @pre && $pre[0] ne 'Q'; + } elsif ($man =~ /^BUR/) { + $tok = 'BUREAU'; } elsif ($man eq 'HC' || $man =~ /^HOM/) { - $man = 'HOME CALL'; + $tok = 'HOME CALL'; } elsif ($man =~ /^QRZ/) { - $man = 'QRZ.com'; + $tok = 'QRZ.com'; } - my ($r) = grep {$_->[0] eq $man} @{$self->[1]}; - if ($r) { - $r->[1]++; - if ($t > $r->[2]) { - $r->[2] = $t; - $r->[3] = $by; + if ($tok) { + my ($r) = grep {$_->[0] eq $tok} @{$self->[1]}; + if ($r) { + $r->[1]++; + if ($t > $r->[2]) { + $r->[2] = $t; + $r->[3] = $by; + } + $changed++; + } else { + $r = [$tok, 1, $t, $by]; + unshift @{$self->[1]}, $r; + $changed++; } - } else { - $r = [$man, 1, $t, $by]; - unshift @{$self->[1]}, $r; } } - $self->put; + $self->put if $changed; } sub get -- 2.43.0