3 # Implement a 'GO' database list
5 # Copyright (c) 2003 Dirk Koopman G1TLH
10 # search local then perl directories
14 # root of directory tree for this system
16 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
18 unshift @INC, "$root/perl"; # this IS the right way round!
19 unshift @INC, "$root/local";
30 my $qslfn = "localqsl";
32 $main::systime = time;
35 my $db = DXDb::getdesc($qslfn);
39 $db = DXDb::getdesc($qslfn);
42 die "cannot load $qslfn $!" unless $db;
44 my $base = "$root/data/spots";
46 opendir YEAR, $base or die "$base $!";
47 foreach my $year (sort readdir YEAR) {
48 next if $year =~ /^\./;
49 my $baseyear = "$base/$year";
50 opendir DAY, $baseyear or die "$baseyear $!";
51 foreach my $day (sort readdir DAY) {
52 next if $day =~ /^\./;
53 my $fn = "$baseyear/$day";
54 my $f = new IO::File $fn or die "$fn ($!)";
57 my ($freq, $call, $t, $comment, $by, @rest) = split /\^/;
58 my $value = $db->getkey($call) || "";
59 my $newvalue = update($value, $call, $t, $comment, $by);
60 if ($newvalue ne $value) {
61 $db->putkey($call, $newvalue);
73 my ($line, $call, $t, $comment, $by) = @_;
74 my @lines = split /\n/, $line;
78 foreach my $l (@lines) {
79 my ($date, $time, $oby, $ocom) = $l =~ /^(\s?\S+)\s+(\s?\S+)\s+by\s+(\S+):\s+(.*)$/;
81 my $ot = cltounix($date, $time);
82 push @in, [$ot, $oby, $ocom];
84 print "Cannot decode $call: $l\n";
90 # is this newer than the earliest one?
91 if (@in && $in[0]->[0] < $t) {
92 @in = grep {$_->[1] ne $by} @in;
94 unshift @in, [$t, $by, $comment];
96 return join "\n", (map {(cldatetime($_->[0]) . " by $_->[1]: $_->[2]")} @in);