Weather::OWM released on CPAN

I am in the process of adding OpenWeatherMap support to Xasteria Weather for iOS and the proxy I built is in Perl. Since there was only an old module on CPAN which did not support the current API and was not easily updatable, I released Weather::OWM. It's a very simple module, similar to two other Weather modules I've released in the past (Weather::WeatherKit and Weather::Astro7Timer).
The OpenWeather API has a Free tier with both current weather and forecast, which makes the module useful to anyone interested in fetching weather for any location. E.g.


use Weather::OWM;
 
my $owm = Weather::OWM->new(key => 'Your API key');

# Get current weather for the Stonehenge area using lat/lon...
my %r = $owm->get_weather(lat => 51.18, lon => -1.83);
 
# ...and print temperature, humidity, wind speed
say "$r{main}->{temp}C $r{main}->{humidity}% $r{wind}->{speed}m/s"
    unless $r{error};

# Get 3h/5d forecast for London, UK...
%r = $owm->get_weather(product => 'forecast', loc => 'London,UK');
 
# ...print the temperature for every 3 hours over the next 5 days
say scalar(localtime($_->{dt}))." $_->{main}->{temp}C"
    for @{$r{list}};

Leave a comment

About Dimitrios Kechagias

user-pic Computer scientist, physicist, amateur astronomer.