X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FGeomag.pm;h=3ee013618f5554443d08c9bc64add9b647e4ff74;hb=d5b4190c36f130852973121042876af3c5642cd7;hp=a63d19b66bbdef6d473e19b0a675eedd802c11a9;hpb=4c0591c17b89dbb049ba119d3f3ea15c5b56128c;p=spider.git diff --git a/perl/Geomag.pm b/perl/Geomag.pm index a63d19b6..3ee01361 100644 --- a/perl/Geomag.pm +++ b/perl/Geomag.pm @@ -142,13 +142,11 @@ sub forecast # sub print { - 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,19 +159,19 @@ sub print \$ref = \$in[\$c]; if ($search) { \$count++; - next if \$count < $from; + next if \$count < \$from; push \@out, print_item(\$ref); last LOOP if \$count >= \$to; # stop after n } } ); - $self->close; # close any open files + $fp->close; # close any open files - my $fh = $self->open(@date); + my $fh = $fp->open(@date); LOOP: while ($count < $to) { - my @spots = (); + my @in = (); if ($fh) { while (<$fh>) { chomp; @@ -182,7 +180,7 @@ LOOP: eval $eval; # do the search on this file return ("Spot search error", $@) if $@; } - $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__;