GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  GEO::WEATHER (3)

.ds Aq ’

NAME

Geo::Weather - Weather retrieval module

CONTENTS

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;
  $weather->{timeout} = 5; # set timeout to 5 seconds instead of the default of 10

  my $current = $weather->get_weather(95630);

  print "The current temperature is $current->{temp} degrees\n";



DESCRIPTION

The <B>Geo::WeatherB> module retrieves the current weather from weather.com when given city and state or a US zip code. <B>Geo::WeatherB> relies on LWP::UserAgent to work. In order for the timeout code to work correctly, you must be using a recent version of libwww-perl and IO::Socket. <B>Geo::WeatherB> was developed with libwww-perl 5.53 and IO::Socket 1.26.

FUNCTIONS

o <B>newB>

Create and return a new object.

o <B>get_weatherB>

Gets the current weather from weather.com

<B>ArgumentsB>



        city - US city or zip code
        state - US state, not needed if using zip code



<B>Sample CodeB>



        my $current = $weather->get_weather(Folsom,CA);
        if (!ref $current) {
                die "Unable to get weather information\n";
        }



<B>ReturnsB>



        On sucess, get_weather returns a hashref  containing the following keys

        city            - City
        state           - State
        zip             - Zipcode of US city
        pic             - weather.com URL to the current weather image
        url             - Weather.com URL to the weather results
        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
        baro            - Current barometric pressure
        heat            - Current heat index (Feels Like string)

        On error, it returns the following exported error variables



<B>ErrorsB>



        $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
        $ERROR_TIMEOUT          - Timed out while trying to connect or get data from weather.com



o <B>reportB>

Returns an HTML table containing the current weather. Must call get_weather first.

<B>Sample CodeB>



        print $weather->report();



o <B>report_rawB>

Returns pipe delimited string containing the current weather. Must call get_weather first.



 Fields are: city|state|pic|cond|temp|wind|dewp|humi|visb|baro|uv



<B>Sample CodeB>



        my $current = $weather->report_raw();



o <B>report_forecastB>

Returns an HTML table containing the ten day forecast. Must call get_weather first.

<B>ArgumentsB>



        table_width - Optional (integer) table width for the report. Default is 80.



<B>Sample CodeB>



        my $forecast = $weather->report_forecast();



o <B>set_report_colorsB>

Set the HTML color values for the weather report. Must call before report or report_forecast to be effective. (DUH!)

<B>ArgumentsB>



        report_hdr_color - Report header color. Default is #000000.
        report_cond_color - Report conditions color. Default is #000080.
        report_result_color - Report reults color. Default is #0000a0.



<B>Sample CodeB>



        my $status = $weather->set_report_colors(#ff0000, #00ff00, #0000ff);



<B>ReturnsB>



        0 if passed a bad value.
        1 if successful.



o <B>data_checkB>

Returns a boolean value indicating if valid weather data appears to have been retrieved. Must call get_weather first.

<B>Sample CodeB>



        my $valid = $weather->data_check();
        unless ($valid) {
                die "The weather data retrieved appears to be bad or missing.\n";
        }



o <B>get_cityB>

Returns string containing the current weather city. This is useful when looking up weather by zip code. Must call get_weather first.

<B>Sample CodeB>



        my $city = $weather->get_city();



o <B>get_stateB>

Returns string containing the current weather state. This is useful when looking up weather by zip code. Must call get_weather first.

<B>Sample CodeB>



        my $state = $weather->get_state();



o <B>lookupB>

Gets current weather given a full weather.com URL

<B>Sample CodeB>



        my $current = $weather->lookup(http://www.weather.com/search/search?where=95630);



<B>ReturnsB>



        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.



o <B>lookup_forecastB>

Gets the ten day forecast page given a full weather.com URL. Not intended to be called directly, but used by report_forecast.

<B>Sample CodeB>



        my $raw_forecast = $weather->lookup_forecast(http://www.w3.weather.com/weather/print/95630);



<B>ReturnsB>



        On sucess, lookup_forecast returns an array containing the weather.com ten day forecast page data.

        On error, lookup_forecast returns the same errors defined for get_weather.



OBJECT KEYS

There are several object hash keys that can be set to manipulate how <B>Geo::WeatherB> works. The hash keys should be set directly following new.

Below is a list of each key and what it does:
o <B>debugB>

Enable debug output of the connection attempts to weather.com Valid values are 0 to 4, increasing debugging respectivley.

o <B>timeoutB>

Controls the timeout, in seconds, when trying to connect to or get data from weather.com. Default timeout is 10 seconds. Set to 0 to disable timeouts.

o <B>proxyB>

Use HTTP proxy for the request. Format is http://proxy.server:port/. Default is no proxy.

o <B>proxy_userB>

Sets the username to use for proxying. Defaults to the HTTP_PROXY_USER environment variable, if set, or don’t use authentication if blank.

o <B>proxy_passB>

Sets the password to use for proxying. Defaults to the HTTP_PROXY_PASS environment variable, if set.

o *<B>agent_stringB>

HTTP User-Agent header for request. Default is Geo::Weather/$VERSION.

AUTHOR



 Geo::Weather was wrtten by Mike Machado I<E<lt>mike@innercite.comE<gt>>



POD ERRORS

Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 888: ’=item’ outside of any ’=over’
Around line 909: Expected ’=item *’
Around line 913: You forgot a ’=back’ before ’=head1’
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 WEATHER (3) 2003-08-27

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.