7 my ($self, $line) = @_;
8 my @list = split /\s+/, $line; # split the line up
14 my ($fromday, $today);
25 my ($doqsl, $doiota, $doqra, $dofilter);
27 while ($f = shift @list) { # next field
28 # print "f: $f list: ", join(',', @list), "\n";
30 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$|; # is it a from -> to count?
31 next if $from && $to > $from;
34 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
37 if (lc $f eq 'dxcc') {
41 if (lc $f eq 'rt' || $f =~ /^real/i) {
45 if (lc $f eq 'on' && $list[0]) { # is it freq range?
47 if ($list[0] =~ m|^(\d+)(?:\.\d+)?[-/](\d+)(?:\.\d+)?$|) {
52 my @r = split '/', lc $list[0];
53 # print "r0: $r[0] r1: $r[1]\n";
54 my @fr = Bands::get_freq($r[0], $r[1]);
55 if (@fr) { # yup, get rid of extranous param
56 # print "freq: ", join(',', @fr), "\n";
57 push @freq, @fr; # add these to the list
63 if (lc $f eq 'day' && $list[0]) {
65 ($fromday, $today) = split m|[-/]|, shift(@list);
68 if (lc $f eq 'info' && $list[0]) {
73 if ((lc $f eq 'spotter' || lc $f eq 'by') && $list[0]) {
74 # print "got spotter\n";
75 $spotter = uc shift @list;
76 if ($list[0] && lc $list[0] eq 'dxcc') {
82 if (lc $f =~ /^filt/) {
90 if (lc $f eq 'iota') {
94 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)-?(\d?\d\d)/oi)) {
96 $doiota = "\\b$a\[\-\ \]\?$b\\b";
99 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[- ]?\d?\d\d)\b' unless $doiota;
102 if (lc $f eq 'qra') {
103 $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/oi;
104 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
112 # first deal with the prefix
117 @ans = Prefix::extract($pre); # is it a callsign/prefix?
121 # first deal with the prefix
122 my $pre = shift @ans;
124 my $str = "Prefix: $pre";
129 # build up a search string for this dxcc country/countries
132 push @expr, "\$f5 == $n";
134 my $name = $a->name();
135 $str .= " Dxcc: $n ($name)";
139 $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
140 $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
144 $pre .= '*' unless $pre =~ /[\*\?\[]/o;
145 $pre = shellregex($pre);
146 $expr = "\$f1 =~ m{$pre}";
152 # now deal with any frequencies specified
154 $expr .= ($expr) ? " && (" : "(";
155 $hint .= ($hint) ? " && (" : "(";
157 for ($i = 0; $i < @freq; $i += 2) {
158 $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
159 my $r = Spot::ftor($freq[$i], $freq[$i+1]);
160 # $hint .= "m{$r\\.} ||" if $r;
161 # $hint .= "m{\d+\.} ||";
164 chop $expr; chop $expr;
165 chop $hint; chop $hint;
172 $expr .= " && " if $expr;
173 $info =~ s{(.)}{"\Q$1"}ge;
174 $expr .= "\$f3 =~ m{$info}i";
175 $hint .= " && " if $hint;
176 $hint .= "m{$info}i";
183 @ans = Prefix::extract($spotter); # is it a callsign/prefix?
187 # first deal with the prefix
188 my $pre = shift @ans;
190 $expr .= ' && ' if $expr;
191 $hint .= ' && ' if $hint;
192 my $str = "Spotter: $pre";
197 # build up a search string for this dxcc country/countries
200 push @expr, "\$f6 == $n";
202 my $name = $a->name();
203 $str .= " Dxcc: $n ($name)";
207 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
208 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
212 $expr .= " && " if $expr;
213 $spotter .= '*' unless $spotter =~ /[\*\?\[]/o;
214 $spotter = shellregex($spotter);
215 $expr .= "\$f4 =~ m{\U$spotter}";
216 $hint .= " && " if $hint;
217 $spotter =~ s/[\^\$]//g;
218 $hint .= "m{\U$spotter}";
224 $expr .= " && " if $expr;
225 $expr .= "\$f3 =~ m{QSL|VIA}i";
226 $hint .= " && " if $hint;
227 $hint .= "m{QSL|VIA}i";
232 $expr .= " && " if $expr;
233 $expr .= "\$f3 =~ m{$doiota}i";
234 $hint .= " && " if $hint;
235 $hint .= "m{$doiota}i";
240 $expr .= " && " if $expr;
241 $expr .= "\$f3 =~ m{$doqra}i";
242 $hint .= " && " if $hint;
243 $hint .= "m{$doqra}io";
246 #print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
249 my @res = Spot::search($expr, $fromday, $today, $from, $to, $hint, $dofilter);
252 foreach $ref (@res) {
254 push @out, $self->format_dx_spot(@$ref);
256 push @out, Spot::formatl(@$ref);