| SoggyOnion documentation | Contained in the SoggyOnion distribution. |
SoggyOnion::Plugin::GeoWeather - get the weather
In config.yaml:
layout:
- title: Weather
name: weather.html
items:
- plugin: SoggyOnion::Plugin::GeoWeather
id: weatherdotcom
zip: '02115'
..or..
- plugin: SoggyOnion::Plugin::GeoWeather
id: weatherdotcom
city: Boston
state: MA
This is a plugin for SoggyOnion that gets the weather.
id - the item ID that appears in the HTML <DIV> tagzipcity and stateIan Langworth, <ian@cpan.org>
Copyright (C) 2004 by Ian Langworth
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| SoggyOnion documentation | Contained in the SoggyOnion distribution. |
package SoggyOnion::Plugin::GeoWeather; use warnings; use strict; use base qw( SoggyOnion::Plugin ); our $VERSION = '0.04'; use Geo::Weather; sub content { my $self = shift; # we need either the city&state or a zip code my @args; if ( exists $self->{zip} ) { @args = ( $self->{zip} ); } elsif ( exists $self->{city} && exists $self->{state} ) { @args = ( $self->{city}, $self->{state} ); } else { warn __PACKAGE__ . " hash must have 'zip' or 'city' and 'state'\n"; return; } # get the weather my $weather = Geo::Weather->new; $weather->get_weather(@args); return $weather->report . "<hr/>" . $weather->report_forecast; } 1; __END__