Weather data via Perl-- just sharing
I got this from a Perl list at Builder.com, I thought it would be interesting to share, something folks may want to include it on their web sites: Retrieve weather data with Geo::WeatherNOAA Perl's WeatherNOAA module gives you easy access to current weather information and short-term forecasts provided by the National Oceanographic and Atmospheric Administration (NOAA). The module exports a handful of functions to retrieve and process weather data. The simplest interface uses the print_forecast( ) and print_current( ) functions. These functions have default values for all parameters except the city and state, which makes them very easy to use. Here's a simple script that will print the forecast and current conditions for a selected city and state (with a default of Louisville, KY). use Geo::WeatherNOAA; $city = shift || 'Louisville'; $state = shift || 'KY'; print Reading weather data for $city, $state ... \n; print Forecast: . print_forecast($city, $state); print \nCurrent: . print_current($city, $state); If you know the city and state that you want weather information for, you can print the forecast right from the command line as follows: perl -MGeo::WeatherNOAA -e print print_forecast('Louisville', 'KY'); The WeatherNOAA module makes it extremely easy to get current weather conditions and forecast data for display on a Web page, a mobile device, or simply for viewing at the console.
another weather question, kinda
ok so im still working away on this weather thing(i would like to thank mark solomon, if he ever reads this stuff, for writing a great weather modual!!!) but im searching a variable for a certain phrase, its not finding it, but i know its there, and i cant figure out whats not matching,(i suck at regular expressions) so look at this: $currentW = qw(At 4:00 PM, Orlando Exec, FL conditions were fair weather at 79°F wind was north at 9 mph. The relative humidity was 52%, and barometric pressure was steady from 30.13 in.); %skies = ( 'SUNNY' = 'sunny skies', 'MOSUNNY'= 'mostly sunny skies', 'PTSUNNY'= 'partly sunny skies', 'CLEAR' = 'clear weather', 'DRIZZLE'= 'a drizzle', 'CLOUDY' = 'cloudy skies', 'MOCLDY' = 'mostly cloudy skies', 'PTCLDY' = 'partly cloudy skies', 'LGT RAIN' = 'light rain', 'FRZ DRZL' = 'freezing drizzle', 'FLURRIES' = 'flurries', 'LGT SNOW' = 'light snow', 'SNOW' = 'snow', 'N/A'= 'N/A', 'NOT AVBL' = '*not available*', 'FAIR' = 'fair weather'); foreach $key (keys(%skies)){ if ($currentW =~ m/'$skies{$key}'/){ $sky = $key; } } if you can see what the im missing help me out, thanx a billion nate
Re: weather
Hi Nate, Take a look at these modules and see if any will do what you want: http://search.cpan.org/search?mode=modulequery=Weather Cheers, Kevin On Mon, Nov 19, 2001 at 01:11:39PM -0800, Nate ([EMAIL PROTECTED]) said something similar to: just a quick question, im would like write a script that goes and gets a weather forcast, does any one know a site that has plain text weather forcast. or if someone who has done this before could help me out on the best way to go about this..maybe? the only way i could think of doing it would be with LWP::Simple; and its get function... but if any one could shed some light on the subject. i would be forever grateful :) thanx -nate -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Deserve it (death)! I daresay he does. Many that live deserve death. And some t hat die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the wise cannot see all end. -- Gandalf (Fellowship of the Ring) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: weather
We use this to turn on or not turn on our sprinklers at home via a serial i/o board: # test weather.com; if we find 'rain' or 'showers' in the forecast for today, # we exit. if (`/usr/local/scripts/GET http://www.weather.com/weather/local/92101|perl -pe 's/.+?//g;' |grep -B 1 Feels Like|head -1|grep -i 'rain|showers'` ne '') { exit; } It seems that weather.com is down at the moment, tho... Le Mon, Nov 19, 2001 at 01:11:39PM -0800, Nate a dit le suivant: } just a quick question, } } im would like write a script that goes and gets a weather forcast, } does any one know a site that has plain text weather forcast. or } if someone who has done this before could help me out on } the best way to go about this..maybe? the only way i could think } of doing it would be with LWP::Simple; and its get function... } but if any one could shed some light on the subject. i would } be forever grateful :) thanx } } -nate -- Namaste, Kristin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]