To that effect I submit the following:
Requires: Geo::METAR
#!/usr/bin/perl -w # Gets METAR information from my Favorite Airports and # displays temp and wind speed direction. use LWP::UserAgent; use Geo::METAR; use strict; my $ua = LWP::UserAgent->new; my $uri = "http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc="; my $m = new Geo::METAR; #airport codes my %code = ( Renton => 'krnt', Ephrata => 'keph', Boeing_Field => 'kbfi', CourDAlene => 'kcoe', Sea_Tac => 'ksea', ); my (%site,$key,$value); while (($key,$value) = each %code) { $site{$value}=$key; } for (keys %code) { $uri .= $code{$_} . "%20"; } my $req = HTTP::Request->new('GET',$uri); my $res = $ua->request($req); if ($res->is_success) { my @content = split("\n",$res->content); if (@content) { for (@content) { if (/\d{6}Z/) { $m->metar($_); print <<"EOT"; Site: $site{lc($m->{SITE})} Time: $m->{TIME} Temp: $m->{F_TEMP} deg F. Wind: $m->{WIND_MPH} mph. Dir: $m->{WIND_DIR_ENG} EOT } } } } else { print "Error: " . $res->status_line . "\n"; }

Update: Per Odud's excellent suggestion, I added error checking on the get. This meant usingLWP::UserAgent rather than LWP::Simple


In reply to RE: RE: RE: Oblivious? by ase
in thread Oblivious? by redmist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.