some detail changes to do with -w flags etc
[spider.git] / cmd / show / dxcc.pl
index 3a2911c583e7bbd9a1904dba450e5cc6428e4269..f5826e47c9be561d208ca62123f35385d1b866c9 100644 (file)
@@ -5,7 +5,7 @@
 #
 
 my ($self, $line) = @_;
-my @list = split /\s+/, $line;               # split the line up
+my @list = split /\s+/, $line; # split the line up
 
 my @out;
 my $f;
@@ -15,85 +15,85 @@ my ($fromday, $today);
 my @freq;
 my @ans;
 
-while ($f = shift @list) {                 # next field
-  print "f: $f list: ", join(',', @list), "\n";
-  if (!$from && !$to) {
-    ($from, $to) = $f =~ /^(\d+)-(\d+)$/o;         # is it a from -> to count?
-    next if $from && $to > $from;
-  }
-  if (!$to) {
-    ($to) = $f =~ /^(\d+)$/o if !$to;              # is it a to count?
-    next if $to;
-  }
-  if (lc $f eq 'on' && $list[0]) {                  # is it freq range?
-    print "yup freq\n";
-    my @r = split '/', $list[0];
-       print "r0: $r[0] r1: $r[1]\n";
-       @freq = Bands::get_freq($r[0], $r[1]);
-       if (@freq) {                 # yup, get rid of extranous param
-         print "freq: ", join(',', @freq), "\n";
-         shift @list;
-         next;
+while ($f = shift @list) {             # next field
+#      print "f: $f list: ", join(',', @list), "\n";
+       if (!$from && !$to) {
+               ($from, $to) = $f =~ /^(\d+)-(\d+)$/o; # is it a from -> to count?
+               next if $from && $to > $from;
+       }
+       if (!$to) {
+               ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
+               next if $to;
+       }
+       if (lc $f eq 'on' && $list[0]) { # is it freq range?
+#              print "yup freq\n";
+               my @r = split '/', $list[0];
+#              print "r0: $r[0] r1: $r[1]\n";
+               @freq = Bands::get_freq($r[0], $r[1]);
+               if (@freq) {                    # yup, get rid of extranous param
+#                      print "freq: ", join(',', @freq), "\n";
+                       shift @list;
+                       next;
+               }
+       }
+       if (lc $f eq 'day' && $list[0]) {
+#              print "got day\n";
+               ($fromday, $today) = split '-', $list[0];
+               shift @list;
+               next;
+       }
+       if (!@ans) {
+               @ans = Prefix::extract($f);     # is it a callsign/prefix?
        }
-  }
-  if (lc $f eq 'day' && $list[0]) {
-    print "got day\n";
-    ($fromday, $today) = split '-', $list[0];
-       shift @list;
-       next;
-  }
-  if (!@ans) {
-    @ans = Prefix::extract($f);                       # is it a callsign/prefix?
-  }
 }
 
 # no dxcc country, no answer!
-if (@ans) {                               # we have a valid prefix!
+if (@ans) {                                            # we have a valid prefix!
   
-  # first deal with the prefix
-  my $pre = shift @ans;
-  my $a;
-  my $expr = "(";
-  my $str = "Prefix: $pre";
-  my $l = length $str;
+       # first deal with the prefix
+       my $pre = shift @ans;
+       my $a;
+       my $expr = "(";
+       my $str = "Prefix: $pre";
+       my $l = length $str;
 
-  # build up a search string for this dxcc country/countries
-  foreach $a (@ans) {
-    $expr .= " || " if $expr ne "(";
-       my $n = $a->dxcc();
-    $expr .= "\$f5 == $n";
-       my $name = $a->name();
-       $str .= " Dxcc: $n ($name)";
+       # build up a search string for this dxcc country/countries
+       foreach $a (@ans) {
+               $expr .= " || " if $expr ne "(";
+               my $n = $a->dxcc();
+               $expr .= "\$f5 == $n";
+               my $name = $a->name();
+               $str .= " Dxcc: $n ($name)";
+               push @out, $str;
+               $str = pack "A$l", " ";
+       }
+       $expr .= ")";
        push @out, $str;
-       $str = pack "A$l", " ";
-  }
-  $expr .= ")";
-  push @out, $str;
   
-  # now deal with any frequencies specified
-  if (@freq) {
-    $expr .= " && (";
-       my $i;
-       for ($i; $i < @freq; $i += 2) {
-         $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
+       # now deal with any frequencies specified
+       if (@freq) {
+               $expr .= " && (";
+               my $i;
+               for ($i = 0; $i < @freq; $i += 2) {
+                       $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
+               }
+               chop $expr;
+               chop $expr;
+               $expr .= ")";
        }
-       chop $expr;
-       chop $expr;
-       $expr .= ")";
-  }
 
-  print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
+#      print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
   
-  # now do the search
-  my @res = Spot::search($expr, $fromday, $today, $from, $to);
-  my $ref;
-  my @dx;
-  foreach $ref (@res) {
-    @dx = @$ref;
-       push @out, Spot::formatl(@dx);
-  }
+       # now do the search
+       my @res = Spot::search($expr, $fromday, $today, $from, $to);
+       my $ref;
+       my @dx;
+       foreach $ref (@res) {
+               @dx = @$ref;
+               push @out, Spot::formatl(@dx);
+       }
 } else {
-  @out = $self->msg('e4');
+       @out = $self->msg('e4');
 }
 
 return (1, @out);