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;
142 # first deal with the prefix
147 @ans = Prefix::extract($pre); # is it a callsign/prefix?
151 # first deal with the prefix
152 my $pre = shift @ans;
154 my $str = "Prefix: $pre";
159 # build up a search string for this dxcc country/countries
162 push @expr, "\$f5 == $n";
164 my $name = $a->name();
165 $str .= " Dxcc: $n ($name)";
169 $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
170 $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
174 $pre .= '*' unless $pre =~ /[\*\?\[]/o;
175 $pre = shellregex($pre);
176 $expr = "\$f1 =~ m{$pre}";
182 # now deal with any frequencies specified
184 $expr .= ($expr) ? " && (" : "(";
185 # $hint .= ($hint) ? " && (" : "(";
187 for ($i = 0; $i < @freq; $i += 2) {
188 $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
189 my $r = Spot::ftor($freq[$i], $freq[$i+1]);
190 # $hint .= "m{$r\\.} ||" if $r;
191 # $hint .= "m{\d+\.} ||";
194 chop $expr; chop $expr;
195 # chop $hint; chop $hint;
202 $expr .= " && " if $expr;
203 $info =~ s{(.)}{"\Q$1"}ge;
204 $expr .= "\$f3 =~ m{$info}i";
205 $hint .= " && " if $hint;
206 $hint .= "m{$info}i";
213 @ans = Prefix::extract($spotter); # is it a callsign/prefix?
217 # first deal with the prefix
218 my $pre = shift @ans;
220 $expr .= ' && ' if $expr;
221 $hint .= ' && ' if $hint;
222 my $str = "Spotter: $pre";
227 # build up a search string for this dxcc country/countries
230 push @expr, "\$f6 == $n";
232 my $name = $a->name();
233 $str .= " Dxcc: $n ($name)";
237 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
238 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
242 $expr .= " && " if $expr;
243 $spotter .= '*' unless $spotter =~ /[\*\?\[]/o;
244 $spotter = shellregex($spotter);
245 $expr .= "\$f4 =~ m{\U$spotter}";
246 $hint .= " && " if $hint;
247 $spotter =~ s/[\^\$]//g;
248 $hint .= "m{\U$spotter}";
256 for (split /[:,]/, $zone) {
257 push @expr, "\$f9==$_";
260 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
261 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
266 for (split /[:,]/, $byzone) {
267 push @expr, "\$f11==$_";
270 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
271 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
278 for (split /[:,]/, $itu) {
279 push @expr, "\$f8==$_";
282 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
283 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
288 for (split /[:,]/, $byitu) {
289 push @expr, "\$f10==$_";
292 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
293 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
300 for (split /[:,]/, $state) {
301 push @expr, "\$f12 eq '$_'";
304 $expr .= @expr > 1 ? '($f12 && (' . join(' || ', @expr) . '))' : "(\$f12 && $expr[0])";
305 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
310 for (split /[:,]/, $bystate) {
311 push @expr, "\$f13 eq '$_'";
314 $expr .= @expr > 1 ? '($f13 && (' . join(' || ', @expr) . '))' : "(\$f13 && $expr[0])";
315 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
320 $expr .= " && " if $expr;
321 $expr .= "\$f3 =~ m{QSL|VIA}i";
322 $hint .= " && " if $hint;
323 $hint .= "m{QSL|VIA}i";
328 $expr .= " && " if $expr;
329 $expr .= "\$f3 =~ m{$doiota}i";
330 $hint .= " && " if $hint;
331 $hint .= "m{$doiota}i";
336 $expr .= " && " if $expr;
337 $expr .= "\$f3 =~ m{$doqra}i";
338 $hint .= " && " if $hint;
339 $hint .= "m{$doqra}io";
342 #print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
345 my @res = Spot::search($expr, $fromday, $today, $from, $to, $hint, $dofilter ? $self : undef);
348 foreach $ref (@res) {
350 push @out, $self->format_dx_spot(@$ref);
352 push @out, Spot::formatl(@$ref);