7 my ($self, $line) = @_;
8 my @list = split /\s+/, $line; # split the line up
14 my ($fromday, $today);
25 my ($doqsl, $doiota, $doqra);
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') {
86 if (lc $f eq 'iota') {
90 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)-?(\d?\d\d)/oi)) {
92 $doiota = "\\b$a\[\-\ \]\?$b\\b";
95 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[- ]?\d?\d\d)\b' unless $doiota;
99 $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/oi;
100 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
108 # first deal with the prefix
113 @ans = Prefix::extract($pre); # is it a callsign/prefix?
117 # first deal with the prefix
118 my $pre = shift @ans;
120 my $str = "Prefix: $pre";
125 # build up a search string for this dxcc country/countries
128 push @expr, "\$f5 == $n";
130 my $name = $a->name();
131 $str .= " Dxcc: $n ($name)";
135 $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
136 $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
140 $pre .= '*' unless $pre =~ /[\*\?\[]/o;
141 $pre = shellregex($pre);
142 $expr = "\$f1 =~ m{$pre}";
148 # now deal with any frequencies specified
150 $expr .= ($expr) ? " && (" : "(";
151 $hint .= ($hint) ? " && (" : "(";
153 for ($i = 0; $i < @freq; $i += 2) {
154 $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
155 my $r = Spot::ftor($freq[$i], $freq[$i+1]);
156 $hint .= "m{$r\\.} ||" if $r;
158 chop $expr; chop $expr;
159 chop $hint; chop $hint;
166 $expr .= " && " if $expr;
167 $info =~ s{(.)}{"\Q$1"}ge;
168 $expr .= "\$f3 =~ m{$info}i";
169 $hint .= " && " if $hint;
170 $hint .= "m{$info}i";
177 @ans = Prefix::extract($spotter); # is it a callsign/prefix?
181 # first deal with the prefix
182 my $pre = shift @ans;
184 $expr .= ' && ' if $expr;
185 $hint .= ' && ' if $hint;
186 my $str = "Spotter: $pre";
191 # build up a search string for this dxcc country/countries
194 push @expr, "\$f6 == $n";
196 my $name = $a->name();
197 $str .= " Dxcc: $n ($name)";
201 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
202 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
206 $expr .= " && " if $expr;
207 $spotter .= '*' unless $spotter =~ /[\*\?\[]/o;
208 $spotter = shellregex($spotter);
209 $expr .= "\$f4 =~ m{\U$spotter}";
210 $hint .= " && " if $hint;
211 $spotter =~ s/[\^\$]//g;
212 $hint .= "m{\U$spotter}";
218 $expr .= " && " if $expr;
219 $expr .= "\$f3 =~ m{QSL|VIA}i";
220 $hint .= " && " if $hint;
221 $hint .= "m{QSL|VIA}i";
226 $expr .= " && " if $expr;
227 $expr .= "\$f3 =~ m{$doiota}i";
228 $hint .= " && " if $hint;
229 $hint .= "m{$doiota}i";
234 $expr .= " && " if $expr;
235 $expr .= "\$f3 =~ m{$doqra}i";
236 $hint .= " && " if $hint;
237 $hint .= "m{$doqra}io";
240 #print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
243 my @res = Spot::search($expr, $fromday, $today, $from, $to, $hint);
246 foreach $ref (@res) {
248 push @out, $self->format_dx_spot(@$ref);
250 push @out, Spot::formatl(@$ref);