Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I just got this module today with the advice of jcwren and it is the easiest way to get the weather from the web. All it takes is a simple snippet like this:
#!/usr/bin/perl use Geo::Weather; my $weather = new Geo::Weather; $weather->get_weather('Philadelphia','PA'); print $weather->report();
And that little bit will come with a weather report that will come out with this (Today, I mean):
<font size=+4>Philadelphia, Pennsylvania</font><br> <img src=" +" border=0> <font size=+3>Mostly Cloudy</font><br> <table border=0> <tr><td><b>Temp</b></td><td>37&deg F</td> <tr><td><b>Wind</b></td><td>From the West at 15 mph</td> <tr><td><b>Dew Point</b></td><td>18&deg F</td> <tr><td><b>Rel. Humidity</b></td><td>39%</td> <tr><td><b>Visibility</b></td><td>unlimited</td> <tr><td><b>Barometer</b></td><td>30.25 inches</td> <tr><td><b>Sunrise</b></td><td>7:14 am</td> <tr><td><b>Sunset</b></td><td>5:16 pm</td> </table>
But if you don't want that big report you can even shorten it to make it more limited and more..fashionable:
use Geo::Weather; my $weather = new Geo::Weather; my $current = $weather->get_weather('19067'); print "The current temperature is $current->{temp} degrees\n";
And that would just print:
The current temperature is 35 degrees
Now, all this code presented is well documented in the module. All the keys are covered with a description next to it. So, in conclusion, this is MUCH easier than going out and writing a whole load of regular expressions to grab the weather where the results might not even be accurate! Trust me, I know. Get it here

UPDATE: In the full report, you can use the zip code in there too for convenience. If your not connected to the internet when you run it, all that will happen is a little error.

In reply to Geo::Weather by damian1301

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (3)
    As of 2019-05-22 02:42 GMT
    Find Nodes?
      Voting Booth?
      Do you enjoy 3D movies?

      Results (138 votes). Check out past polls.

      • (Sep 10, 2018 at 22:53 UTC) Welcome new users!