NAME
Geo::Weather - Weather retrieval module
SYNOPSIS
use Geo::Weather;
my $weather = new Geo::Weather;
$weather->get_weather('Folsom','CA');
print $weather->report();
-or-
use Geo::Weather;
my $weather = new Geo::Weather;
my $current = $weather->get_weather('95630');
print "The current temperature is $current->{temp} degrees\n";
DESCRIPTION
The Geo::Weather module retrieves the current weather from weather.com when given city and state or a US zip code
FUNCTIONS
new
Create and return a new object.
get_weather
Gets the current weather from weather.com
Arguments
city - US city or zip code state - US state, not needed if using zip code
Sample Code
my $current = $weather->get_weather('Folsom','CA'); if (!ref $current) { die "Unable to get weather information\n"; }
Returns
On sucess, get_weather returns a hashref containing the following keys city - City state - State pic - weather.com URL to the current weather image cond - Current condition temp - Current temperature (degees F) wind - Current wind speed dewp - Current dew point (degrees F) humi - Current rel. humidity visb - Current visibility (miles) baro - Current barometric pressure rise - Sunrise time set - Sunset time On error, it returns the following exported error variables
Errors
$ERROR_QUERY - Invalid data supplied $ERROR_PAGE_INVALID - No URL, or incorrectly formatted URL for retrieving the information $ERROR_CONNECT - Error connecting to weather.com $ERROR_NOT_FOUND - Weather for the specified city/state or zip could not be found
report
Returns an HTML table containing the current weather. Must call get_weather first.
Sample Code
print $weather->report();
lookup
Gets current weather given a full weather.com URL
Sample Code
my $current = $weather->lookup('http://www.weather.com/weather/cities/us_ca_folsom.html');
Returns
On sucess, lookup returns a hashref with the same keys as the get_weather function On error, lookup returns the same errors defined for get_weather
AUTHOR
Geo::Weather was wrtten by Mike Machado I<E<lt>mike@innercite.comE<gt>> with the main weather.com retrieval code from I<E<lt>hawk@redtailedhawk.netE<gt>>