X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FSpot.pm;h=08520c5b47f1108ec26d33d7195372d089cb0dca;hb=624a291612bd3adf9dc02ec813a213109331b4c9;hp=e86354d77b01fe7b8017a225f557c54a25109dfd;hpb=21e7642d216656c60b164d76208633a0c81cf5db;p=spider.git diff --git a/perl/Spot.pm b/perl/Spot.pm index e86354d7..08520c5b 100644 --- a/perl/Spot.pm +++ b/perl/Spot.pm @@ -12,16 +12,24 @@ use FileHandle; use DXVars; use DXDebug; use Julian; +use Prefix; +use Carp; @ISA = qw(Julian); use strict; +use vars qw($fp $maxspots $defaultspots $maxdays $dirprefix); -my $fp; -my $maxspots = 50; # maximum spots to return -my $defaultspots = 10; # normal number of spots to return -my $maxdays = 35; # normal maximum no of days to go back -my $prefix = "$main::data/spots"; +$fp = undef; +$maxspots = 50; # maximum spots to return +$defaultspots = 10; # normal number of spots to return +$maxdays = 35; # normal maximum no of days to go back +$dirprefix = "$main::data/spots"; + +sub prefix +{ + return $dirprefix; +} # add a spot to the data file (call as Spot::add) sub add @@ -32,6 +40,9 @@ sub add $spot[0] = 0 + $spot[0]; $spot[2] = 0 + $spot[2]; + # remove ssid if present on spotter + $spot[4] =~ s/-\d+$//o; + # compare dates to see whether need to open another save file (remember, redefining $fp # automagically closes the output file (if any)) my @date = Julian::unixtoj($spot[2]); @@ -39,6 +50,11 @@ sub add # save it my $fh = $fp->{fh}; + + # add the 'dxcc' country on the end + my @dxcc = Prefix::extract($spot[1]); + push @spot, (@dxcc > 0 ) ? $dxcc[1]->dxcc() : 0; + $fh->print(join("\^", @spot), "\n"); } @@ -53,6 +69,7 @@ sub add # $f2 = date in unix format # $f3 = comment # $f4 = spotter +# $f5 = dxcc country # # In addition you can specify a range of days, this means that it will start searching # from days less than today to days less than today @@ -93,14 +110,9 @@ sub search $to = $defaultspots; } - $expr =~ s/\$f(\d)/zzzref->[$1]/g; # swap the letter n for the correct field name - $expr =~ s/[\@\$\%\{\}]//g; # remove any other funny characters - $expr =~ s/\&\w+\(//g; # remove subroutine calls - $expr =~ s/eval//g; # remove eval words - $expr =~ s/zzzref/\$ref/g; # put back the $ref - $expr =~ s|(/.+/)|$1oi|g; # add oi characters to /ccc/ + $expr =~ s/\$f(\d)/\$ref->[$1]/g; # swap the letter n for the correct field name - print "expr=($expr), from=$from, to=$to\n"; + dbg("search", "expr='$expr', spotno=$from-$to, day=$dayfrom-$dayto\n"); # build up eval to execute $eval = qq(my \$c; @@ -141,7 +153,7 @@ LOOP: sub open { my $pkg = shift; - return Julian::open("spot", $prefix, @_); + return Julian::open("spot", $dirprefix, @_); } # close a spot file