Perl checks for rain and issues umbrella warning

Rain Check

Article from Issue 172/2015
Author(s):

A Perl script that retrieves the current weather forecast at dawn helps the Perlmeister decide whether to run the risk or take an umbrella just in case.

In the wet season, the question often arises as to whether rain or snow will fall from the sky during the day and therefore whether it might be advisable to take an umbrella with me to work.

Underground Weather

Ultimately, however, even occasional rain showers around noon would be irrelevant, as long as you could navigate the commute to and from work without getting wet. Luckily, the Weather Underground [1] weather service offers free forecasts for the day. Although they are certainly not 100 percent accurate, they do beat human intuition by a mile.

On CPAN, Perl programmers will find the WWW::Wunderground::API module, which uses a script to fetch the weather data from the server thanks to a free API developer key [2] procured especially for that purpose. The simple script in Listing 1 uses the module; it iterates over the hourly entries in the bulk of JSON data returned and outputs the time and the probability of rain for each hour sent in the pop (probability of precipitation) [3] entry.

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Maluuba nAPI

    Add natural language processing to your own applications with Maluuba's Natural Language API (nAPI)

  • Maluuba nAPI

    Add natural language processing to your own applications with Maluuba’s Natural Language API (nAPI).

  • Charly's Column: Weather Page

    To find out what the weather is like, sys admin columnist Charly Kühnast no longer needs to go outdoors get wet, blown away, frozen to death, or sunburned.

  • Switch power outlets on and off with home automation tools

    The "If This Then That" web service lets you simply click together home automation components, instead of laboriously integrating them via their APIs. However, you still have to open the hood for the nitty gritty where applicable.

  • Perl: Linux-based Gardening

    In this month’s Perl column, we will introduce a system to water your plants while you are away from home. With a little help from Perl, a friendly, Linux-based irrigation system waters your plants twice a day.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News