#!
# External libraries
use WWW::Mechanize;
# Create local instances
my $agent = WWW::Mechanize->new();
open(EX, ">Barometer.TXT") || die "ERROR! Unknown problem opening TXT file. It may be in use.";
# Go grab the web page into content
$agent->get("http://weather.yahoo.com/forecast/USCA0195_f.html");
# Change URL to match desired zip code
# Find the word AT: and grab the timestamp following it
# match the string 'at: nn:nn a|pm PS|DT-->'
$agent->{content} =~ m/at:\s\d{1,2}:\d\d\s\S\S\s\S\S\S/;
$t = $&;
$t =~ s/://;
$t =~ s/PST/Pacific Time/;
$t =~ s/PDT/Pacific Daylight Time/;
print (EX $t);
# match the string 'Barometer:'
$agent->{content} =~ m/Barometer:/;
print (EX " the Barometric pressure is ");
# Find the end of the line and grab the pressure
$agent->{content} =~ m/\d\d\D\d\d\sin\s\S\S\S/;
$t = $&;
$t =~ s/ in / inches of mercury /;
print (EX "$t ");
$agent->{content} =~ m/falling|steady|rising/;
$t = $&;
print (EX $t);
print (EX ", according to yahoo");
close(EX);
|