My ditigal almanac

brian_d_foy on 2003-01-20T07:34:01

Since I do so much farming now that I live in the midwest, I needed to add sunrise and sunset times to my weather script (and maybe Andy Lester can use this to plan his Extreme Mowing). I still want to add tide information for places next to water, and a three day weather forecast would be nice (although I want to grab that from somewhere that I am allowed to get it---I am not so sure about the Perl module that scrapes weather.com). If I get really fancy I can add the current terrorism threat level, ozone alerts, snow days, and presence of Randal Schwartz in that city.

And, as a globetrotting professional <something>, I would like to have a handy-dandy almanac for places like Kabul, the Sinai, and other places many people learn about on CNN.

#!/usr/bin/perl
# $Id$

use Astro::Sunrise; use Geo::WeatherNOAA;

my @date = localtime;

$date[5] += 1900; $date[4] += 1;

while( ) { next unless m/\|/; chomp; my( $city, $state, $name, $lat, $long, $tz ) = split /\|/; $name ||= $city; my $response = uc( $name ) . "\n"; $response .= print_current( $city, $state, '', 'get'); $response =~ s/°//g; $response .= "\n" unless substr( $response, -1, 1 ) eq "\n"; my( $rise, $set ) = sunrise( @date[5,4,3], $long, $lat, $tz, $date[8] ); print $response, "Sunrise: $rise Sunset: $set\n", "-" x 73, "\n"; } __DATA__ meigs|il|Chicago|41.9|-87.9|-6 providence|ri||41.8|-71.5|-5 new york city|ny||40.8|-74|-5 monterey|ca||36.5|-121.9|-8 CINC-COVINGTON|oh|Cincinnati|39.2|-84.5|-5 atlanta|ga||33.6|-84.5|-5 salt lake city|ut||40.8|-112|-7 dfw airport|tx|Dallas|32.9|-96.9|-6