Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Underground(3)	      User Contributed Perl Documentation	Underground(3)

NAME
       Weather::Underground - Perl extension for retrieving weather
       information from	wunderground.com

SYNOPSIS
	       use Weather::Underground;

	       $weather	= Weather::Underground->new(
		       place =>	"Montreal, Canada",
		       debug =>	0,
		       )
		       || die "Error, could not	create new weather object: $@\n";

	       $arrayref = $weather->get_weather()
		       || die "Error, calling get_weather() failed: $@\n";

	       foreach (@$arrayref) {
		       print "MATCH:\n";
		       while (($key, $value) = each %{$_}) {
			       print "\t$key = $value\n";
		       }
	       }

DESCRIPTION
       Weather::Underground is a perl module which provides a simple OO
       interface to retrieving weather data for	a geographic location.	It
       does so by querying wunderground.com and	parsing	the returned results.

CONSTRUCTOR
       new(hash	or hashref);
	   Creates and returns a new Weather::Underground object.

	   Takes either	a hash (as the SYNOPSIS	shows) or a hashref

	   Required keys in the	hash:

	   place
	       This key	should be assigned the value of	the geographical place
	       you would like to retrieve the weather information for.	The
	       format of specifying the	place really depends on
	       wunderground.com	more than it depends on	this perl module,
	       however at the time of this writing they	accept 'City', 'City,
	       State', 'State',	'State,	Country' and 'Country'.

	   Optional keys in the	hash:

	   cache_file
	       This key	should be assigned a file name to use as a cache.  The
	       module will store and use data from that	file instead of
	       querying	wunderground.com if cache_max_age has not been
	       exceeded.

	       This key	is ignored if the cache_max_age	key is not supplied.

	   cache_max_age
	       This key	should be assigned a numeric value which is the	number
	       of seconds after	which any data in the cache_file will be
	       considered too old and a	new request will be made to
	       wunderground.com

	       This key	is ignored if the cache_file key is not	supplied.

	   debug
	       This key	should be set to a true	or false false.	A false	value
	       means no	debugging information will be printed, a true value
	       means debug information will be printed.

	   timeout
	       If the default timeout for the LWP::UserAgent request (180
	       seconds at the time of this writing) is not enough for you, you
	       can change the timeout by providing this	key.  It should
	       contain the timeout for the HTTP	request	seconds	in seconds.

METHODS
       get_weather()
	   This	method is used to initiate the connection to wunderground.com,
	   query their system, and parse the results or	retrieve the results
	   from	the cache_file constructor key if appropriate.

	   If no results are found, returns undef.

	   If results are found, returns an array reference.  Each element in
	   the array is	a hash reference. Each hash contains information about
	   a place that	matched	the query;

	   Each	hash contains the following keys:

	   place
	       (the exact place	that was matched)

	   temperature_celsius
	       (the temperature	in celsius)

	   temperature_fahrenheit
	       (the temperature	in fahrenheit)

	   humidity
	       (humidity percentage)

	   conditions
	       (current	sky, example: 'Partly cloudy')

	   wind_direction
	       (wind direction,	example: "North")

	   wind_milesperhour
	       (wind speed in miles per	hour)

	   wind_kilometersperhour
	       (wind speed in kilometers per hour)

	   pressure
	       (the barometric pressure)

	   updated
	       (when the content was last updated on the server)

	   clouds
	       (description of clouds)

	   dewpoint_celsius
	       (the dew	point in celsius)

	   dewpoint_fahrenheit
	       (the dew	point in fahrenheit)

	   moonphase
	       (phase of the moon, example: "Full Moon")

	   moonrise
	       (time of	moon rise, including timezone)

	   moonset
	       (time of	moon setting, including	timezone)

	   sunrise
	       (time of	sun rising, including timezone)

	   sunset
	       (time of	sun setting, including timezone)

	   visibility_miles
	       (visibility in miles)

	   visibility_kilometers
	       (visibility in kilometers)

NOTICE
       1.  Your	query may result in more than 1	match. Each match is a hash
	   reference added as a	new value in the array which get_weather()
	   returns the reference to.

       2.  Due to the differences between single and multiple-location
	   matches, some of the	keys listed above may not be available in
	   multi-location matches.

EXAMPLES
       Example 1: Print	all matching information
		   See SYNOPSIS

       Example 2: Print	the Celsius temperature	of the first matching place
		   use Weather::Underground;

		   $weather = Weather::Underground->new(
			   place   =>	   "Montreal",
			   debug	   =>	   0
			   )
			   || die "Error, could	not create new weather object: $@\n";

		   $arrayref = $weather->get_weather()
			   || die "Error, calling get_weather()	failed:	$@\n";

		   print "The celsius temperature at $arrayref->[0]->{place} is	$arrayref->[0]->{temperature_celsius}\n";

ERRORS
       All methods return something that evaluates to true when	successful, or
       undef when not successful.

       If the constructor or a method returns undef, the variable $@ will
       contain a text string containing	the error that occurred.

AUTHOR
       Mina Naguib http://mina.naguib.ca mnaguib@cpan.org

COPYRIGHT
       Copyright (C) 2002-2005 Mina Naguib.  All rights	reserved.  Use is
       subject to the Perl license.

perl v5.32.0			  2011-07-21			Underground(3)

NAME | SYNOPSIS | DESCRIPTION | CONSTRUCTOR | METHODS | NOTICE | EXAMPLES | ERRORS | AUTHOR | COPYRIGHT

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Weather::Underground&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help