/usr/local/bin/perl -w use strict; use WWW::Wunderground::API; use DateTime; use Log::Log4perl qw(:easy); use Getopt::Std; getopts "v", \my %opts; Log::Log4perl->easy_init( $opts{ v } ? $DEBUG : $ERROR); my @critical_hours = qw(8 9 17 18 19); my $w = WWW::Wunderground::API->new( location => "Munich, Germany", api_key => "0123456789abcdef", auto_api => 1, ); for my $e (@{ $w->hourly }) { if( !scalar @critical_hours ) { last; } my $dt = DateTime->from_epoch( epoch => $e->{ FCTTIME }->{ epoch } ); if( $dt->hour() == $critical_hours[0] ) { DEBUG "Checking hour ", $dt->hour(), " ($e->{ pop }%)"; if( $e->{ pop } > 50 ) { printf "Bring your Umbrella! " . "(%d%% rain at %s)\n", $e->{ pop }, $dt->hms(); } shift @critical_hours; } }