7 my ($self, $line) = @_;
8 my @list = split /\s+/, $line; # split the line up
14 my ($fromday, $today);
24 my ($doqsl, $doiota, $doqra);
26 while ($f = shift @list) { # next field
27 # print "f: $f list: ", join(',', @list), "\n";
29 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$|; # is it a from -> to count?
30 next if $from && $to > $from;
33 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
36 if (lc $f eq 'dxcc') {
40 if (lc $f eq 'on' && $list[0]) { # is it freq range?
42 if ($list[0] =~ m|^(\d+)(?:\.\d+)?[-/](\d+)(?:\.\d+)?$|) {
47 my @r = split '/', lc $list[0];
48 # print "r0: $r[0] r1: $r[1]\n";
49 my @fr = Bands::get_freq($r[0], $r[1]);
50 if (@fr) { # yup, get rid of extranous param
51 # print "freq: ", join(',', @fr), "\n";
52 push @freq, @fr; # add these to the list
58 if (lc $f eq 'day' && $list[0]) {
60 ($fromday, $today) = split m|[-/]|, shift(@list);
63 if (lc $f eq 'info' && $list[0]) {
68 if ((lc $f eq 'spotter' || lc $f eq 'by') && $list[0]) {
69 # print "got spotter\n";
70 $spotter = uc shift @list;
71 if ($list[0] && lc $list[0] eq 'dxcc') {
81 if (lc $f eq 'iota') {
85 if ($list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)-?(\d?\d\d)/oi)) {
87 $doiota = "\\b$a\[\-\ \]\?$b\\b";
90 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[- ]?\d?\d\d)\b' unless $doiota;
94 $doqra = uc shift @list if $list[0] =~ /[A-Z][A-Z]\d\d/oi;
95 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
103 # first deal with the prefix
108 @ans = Prefix::extract($pre); # is it a callsign/prefix?
112 # first deal with the prefix
113 my $pre = shift @ans;
115 my $str = "Prefix: $pre";
120 # build up a search string for this dxcc country/countries
123 push @expr, "\$f5 == $n";
125 my $name = $a->name();
126 $str .= " Dxcc: $n ($name)";
130 $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
131 $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
135 $pre .= '*' unless $pre =~ /[\*\?\[]/o;
136 $pre = shellregex($pre);
137 $expr = "\$f1 =~ m{$pre}";
143 # now deal with any frequencies specified
145 $expr .= ($expr) ? " && (" : "(";
146 $hint .= ($hint) ? " && (" : "(";
148 for ($i = 0; $i < @freq; $i += 2) {
149 $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
150 my $r = Spot::ftor($freq[$i], $freq[$i+1]);
151 $hint .= "m{$r\\.} ||" if $r;
153 chop $expr; chop $expr;
154 chop $hint; chop $hint;
161 $expr .= " && " if $expr;
162 $info =~ s{(.)}{"\Q$1"}ge;
163 $expr .= "\$f3 =~ m{$info}i";
164 $hint .= " && " if $hint;
165 $hint .= "m{$info}i";
172 @ans = Prefix::extract($spotter); # is it a callsign/prefix?
176 # first deal with the prefix
177 my $pre = shift @ans;
179 $expr .= ' && ' if $expr;
180 $hint .= ' && ' if $hint;
181 my $str = "Spotter: $pre";
186 # build up a search string for this dxcc country/countries
189 push @expr, "\$f6 == $n";
191 my $name = $a->name();
192 $str .= " Dxcc: $n ($name)";
196 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
197 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
201 $expr .= " && " if $expr;
202 $spotter .= '*' unless $spotter =~ /[\*\?\[]/o;
203 $spotter = shellregex($spotter);
204 $expr .= "\$f4 =~ m{\U$spotter}";
205 $hint .= " && " if $hint;
206 $spotter =~ s/[\^\$]//g;
207 $hint .= "m{\U$spotter}";
213 $expr .= " && " if $expr;
214 $expr .= "\$f3 =~ m{QSL|VIA}i";
215 $hint .= " && " if $hint;
216 $hint .= "m{QSL|VIA}i";
221 $expr .= " && " if $expr;
222 $expr .= "\$f3 =~ m{$doiota}i";
223 $hint .= " && " if $hint;
224 $hint .= "m{$doiota}i";
229 $expr .= " && " if $expr;
230 $expr .= "\$f3 =~ m{$doqra}i";
231 $hint .= " && " if $hint;
232 $hint .= "m{$doqra}io";
235 #print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
238 my @res = Spot::search($expr, $fromday, $today, $from, $to, $hint);
241 foreach $ref (@res) {
242 push @out, Spot::formatl(@$ref);