7 my ($self, $line) = @_;
8 my @list = split /\s+/, $line; # split the line up
14 my ($fromday, $today);
31 my ($doqsl, $doiota, $doqra, $dofilter);
33 while ($f = shift @list) { # next field
34 # print "f: $f list: ", join(',', @list), "\n";
36 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$|; # is it a from -> to count?
37 next if $from && $to > $from;
40 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
43 if (lc $f eq 'dxcc') {
47 if (lc $f eq 'rt' || $f =~ /^real/i) {
51 if (lc $f eq 'on' && $list[0]) { # is it freq range?
53 if ($list[0] =~ m|^(\d+)(?:\.\d+)?[-/](\d+)(?:\.\d+)?$|) {
58 my @r = split '/', lc $list[0];
59 # print "r0: $r[0] r1: $r[1]\n";
60 my @fr = Bands::get_freq($r[0], $r[1]);
61 if (@fr) { # yup, get rid of extranous param
62 # print "freq: ", join(',', @fr), "\n";
63 push @freq, @fr; # add these to the list
69 if (lc $f eq 'day' && $list[0]) {
71 ($fromday, $today) = split m|[-/]|, shift(@list);
74 if (lc $f eq 'info' && $list[0]) {
79 if ((lc $f eq 'spotter' || lc $f eq 'by') && $list[0]) {
80 # print "got spotter\n";
81 $spotter = uc shift @list;
82 if ($list[0] && lc $list[0] eq 'dxcc') {
88 if (lc $f =~ /^filt/) {
89 $dofilter = 1 if $self->spotsfilter;
96 if (lc $f eq 'iota') {
100 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)-?(\d?\d\d)/oi)) {
102 $doiota = "\\b$a\[\-\ \]\?$b\\b";
105 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[- ]?\d?\d\d)\b' unless $doiota;
108 if (lc $f eq 'qra') {
109 $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/oi;
110 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
113 if (lc $f eq 'zone') {
114 $zone = shift @list if @list;
117 if (lc $f =~ /^by_?zone/) {
118 $byzone = shift @list if @list;
121 if (lc $f eq 'itu') {
122 $itu = shift @list if @list;
125 if (lc $f =~ /^by_?itu/) {
126 $byitu = shift @list if @list;
129 if (lc $f eq 'state') {
130 $state = uc shift @list if @list;
133 if (lc $f =~ /^by_?state/) {
134 $bystate = uc shift @list if @list;
144 # first deal with the prefix
149 @ans = Prefix::extract($pre); # is it a callsign/prefix?
153 # first deal with the prefix
154 my $pre = shift @ans;
156 my $str = "Prefix: $pre";
161 # build up a search string for this dxcc country/countries
164 push @expr, "\$f5 == $n";
166 my $name = $a->name();
167 $str .= " Dxcc: $n ($name)";
171 $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
172 $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
176 $pre .= '*' unless $pre =~ /[\*\?\[]/o;
177 $pre = shellregex($pre);
178 $expr = "\$f1 =~ m{$pre}";
184 # now deal with any frequencies specified
186 $expr .= ($expr) ? ' && (' : "(";
187 # $hint .= ($hint) ? ' && ' : "(";
188 # $hint .= ' && ' if $hint;
190 for ($i = 0; $i < @freq; $i += 2) {
191 $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
192 my $r = Spot::ftor($freq[$i], $freq[$i+1]);
193 # $hint .= "m{$r\\.} ||" if $r;
194 # $hint .= "m{\d+\.} ||";
197 chop $expr; chop $expr;
198 # chop $hint; chop $hint;
205 $expr .= ' && ' if $expr;
206 $info =~ s{(.)}{"\Q$1"}ge;
207 $expr .= "\$f3 =~ m{$info}i";
208 $hint .= ' && ' if $hint;
209 $hint .= "m{$info}i";
216 @ans = Prefix::extract($spotter); # is it a callsign/prefix?
220 # first deal with the prefix
221 my $pre = shift @ans;
223 $expr .= ' && ' if $expr;
224 $hint .= ' && ' if $hint;
225 my $str = "Spotter: $pre";
230 # build up a search string for this dxcc country/countries
233 push @expr, "\$f6 == $n";
235 my $name = $a->name();
236 $str .= " Dxcc: $n ($name)";
240 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
241 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
245 $expr .= ' && ' if $expr;
246 $spotter .= '*' unless $spotter =~ /[\*\?\[]/o;
247 $spotter = shellregex($spotter);
248 $expr .= "\$f4 =~ m{\U$spotter}";
249 $hint .= ' && ' if $hint;
250 $spotter =~ s/[\^\$]//g;
251 $hint .= "m{\U$spotter}";
259 $expr .= ' && ' if $expr;
260 $hint .= ' && ' if $hint;
261 for (split /[:,]/, $zone) {
262 push @expr, "\$f9==$_";
265 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
266 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
271 $expr .= ' && ' if $expr;
272 $hint .= ' && ' if $hint;
273 for (split /[:,]/, $byzone) {
274 push @expr, "\$f11==$_";
277 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
278 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
285 $expr .= ' && ' if $expr;
286 $hint .= ' && ' if $hint;
287 for (split /[:,]/, $itu) {
288 push @expr, "\$f8==$_";
291 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
292 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
297 $expr .= ' && ' if $expr;
298 $hint .= ' && ' if $hint;
299 for (split /[:,]/, $byitu) {
300 push @expr, "\$f10==$_";
303 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
304 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
311 $expr .= ' && ' if $expr;
312 $hint .= ' && ' if $hint;
313 for (split /[:,]/, $state) {
314 push @expr, "\$f12 eq '$_'";
317 $expr .= @expr > 1 ? '($f12 && (' . join(' || ', @expr) . '))' : "(\$f12 && $expr[0])";
318 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
323 $expr .= ' && ' if $expr;
324 $hint .= ' && ' if $hint;
325 for (split /[:,]/, $bystate) {
326 push @expr, "\$f13 eq '$_'";
329 $expr .= @expr > 1 ? '($f13 && (' . join(' || ', @expr) . '))' : "(\$f13 && $expr[0])";
330 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
335 $expr .= ' && ' if $expr;
336 $expr .= "\$f3 =~ m{QSL|VIA}i";
337 $hint .= ' && ' if $hint;
338 $hint .= "m{QSL|VIA}i";
343 $expr .= ' && ' if $expr;
344 $expr .= "\$f3 =~ m{$doiota}i";
345 $hint .= ' && ' if $hint;
346 $hint .= "m{$doiota}i";
351 $expr .= ' && ' if $expr;
352 $expr .= "\$f3 =~ m{$doqra}i";
353 $hint .= ' && ' if $hint;
354 $hint .= "m{$doqra}io";
357 #print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
360 my @res = Spot::search($expr, $fromday, $today, $from, $to, $hint, $dofilter ? $self : undef);
363 foreach $ref (@res) {
365 push @out, VE7CC::dx_spot($self, @$ref);
368 push @out, $self->format_dx_spot(@$ref);
370 push @out, Spot::formatl(@$ref);