Public feed #726980

foxhacker

public text v1 · immutable
Raw Edit
·published 2007-10-05 17:28 UTC
rendered paste body
#!/usr/bin/env perl

#use strict;
use warnings;

my @toks;
while(<>){
  if(/(\S+)\s+ASH\s+CLOUD/oi){
    push @toks, [ 'ASH CLOUD', $1 ];
  }
  map {
    if(/([NSEW]\d+)/){
      push @toks, [ 'COORD', $1 ];
    }
  } split(/\s+/, $_);
}

#print "-= Tokens =-\n";
#map {
#  print "$_->[0]: $_->[1]\n";
#} @toks;

#print "-= OBS Coordinates =-\n";
my $print_coords = 0;
map {
  if($_->[0] eq 'ASH CLOUD'){
    if($_->[1] eq 'OBS'){
      $print_coords = 1;
    } else {
      $print_coords = 0;
    }
  }
  if($_->[0] eq 'COORD' and
     $print_coords){
        $bar=substr ($_->[1],0,1);
        if($bar eq "S" || $bar eq "W"){
        $foo=substr ($_->[1],1,5);
        $foo=-$foo/100;
        $lat = $foo;
        $lon = $foo;
        print "$lat , $lon\n";

        }
        else {
        $foo=substr ($_->[1],1,5);
        $foo=$foo/100;
        print "$foo ";
        }
  }
} @toks;

exit 0;