1. Various detail changes to remove some more warning with -w on
[spider.git] / perl / Geomag.pm
index a63d19b66bbdef6d473e19b0a675eedd802c11a9..8b0d2ea7f4cd0933757ed90f6ac68d174ca9bd3b 100644 (file)
@@ -140,15 +140,13 @@ sub forecast
 #
 # This command outputs a list of n lines starting from line $from to $to
 #
-sub print
+sub search
 {
-       my $self = $fp;
        my $from = shift;
        my $to = shift;
-       my @date = $self->unixtoj(shift);
+       my @date = $fp->unixtoj(shift);
        my $pattern = shift;
        my $search;
-       my @in;
        my @out;
        my $eval;
        my $count;
@@ -161,28 +159,28 @@ sub print
                                        \$ref = \$in[\$c];
                                        if ($search) {
                                                \$count++;
-                                               next if \$count < $from;
-                                               push \@out, print_item(\$ref);
-                                               last LOOP if \$count >= \$to;                  # stop after n
+                                               next if \$count < \$from;
+                                               push \@out, \$ref;
+                                               last if \$count >= \$to;                  # stop after n
                                        }
                                }
                          );
        
-       $self->close;                                      # close any open files
+       $fp->close;                                      # close any open files
 
-       my $fh = $self->open(@date); 
-LOOP:
-       while ($count < $to) {
-               my @spots = ();
+       my $fh = $fp->open(@date); 
+       for ($count = 0; $count < $to; ) {
+               my @in = ();
                if ($fh) {
                        while (<$fh>) {
                                chomp;
                                push @in, [ split '\^' ] if length > 2;
                        }
                        eval $eval;               # do the search on this file
-                       return ("Spot search error", $@) if $@;
+                       return ("Geomag search error", $@) if $@;
+                       last if $count >= $to;                  # stop after n
                }
-               $fh = $self->openprev();      # get the next file
+               $fh = $fp->openprev();      # get the next file
                last if !$fh;
        }
 
@@ -209,5 +207,23 @@ sub print_item
        return sprintf("$d   %02d %5d %3d %3d %-37s <%s>", $t, $ref[2], $ref[3], $ref[4], $ref[5], $ref[0]);
 }
 
+#
+# read in this month's data
+#
+sub readfile
+{
+       my @date = $fp->unixtoj(shift);
+       my $fh = $fp->open(@date); 
+       my @spots = ();
+       my @in;
+       
+       if ($fh) {
+               while (<$fh>) {
+                       chomp;
+                       push @in, [ split '\^' ] if length > 2;
+               }
+       }
+       return @in;
+}
 1;
 __END__;