#!/usr/bin/perl -w use strict; use CGI qw(-oldstyle_urls :standard); use XML::TreePP; use XML::XPath; use XML::Simple; use Data::Dumper; use Date::Format; use Date::Parse; my $q = new CGI; $| = 1; my @zipcode = qw(02151 01908 02638 02669 02670 02536 02642 02574 02332 02601 02045 01930 02152 27943 02169); my ($currtempf, $currtempc, $currhumidity, $currcondition, $currwind, $todayhigh, $todaylow, $todaycond, $tomorrowcond); my ($city, $url, $tpp, $tree); foreach my $zip(@zipcode) { next unless $zip =~ /^(\d{5})$/; $url = "http://www.google.com/ig/api?weather=".$zip ; $tpp = XML::TreePP->new(); $tree = $tpp->parsehttp( GET => $url ); $city = $tree->{xml_api_reply}->{weather}->{forecast_information}->{city}->{"-data"} || ''; $currtempf =$tree->{xml_api_reply}->{weather}->{current_conditions}->{temp_f}->{"-data"} || ''; $currtempc =$tree->{xml_api_reply}->{weather}->{current_conditions}->{temp_c}->{"-data"} || ''; $currhumidity =$tree->{xml_api_reply}->{weather}->{current_conditions}->{humidity}->{"-data"} || ''; $currcondition =$tree->{xml_api_reply}->{weather}->{current_conditions}->{condition}->{"-data"} || ''; $currwind =$tree->{xml_api_reply}->{weather}->{current_conditions}->{wind_condition}->{"-data"} || ''; $todayhigh =$tree->{xml_api_reply}->{weather}->{forecast_conditions}->[0]->{high}->{"-data"} || ''; $todaylow =$tree->{xml_api_reply}->{weather}->{forecast_conditions}->[0]->{low}->{"-data"} || ''; $todaycond =$tree->{xml_api_reply}->{weather}->{forecast_conditions}->[0]->{condition}->{"-data"} || ''; $tomorrowcond =$tree->{xml_api_reply}->{weather}->{forecast_conditions}->[1]->{condition}->{"-data"} || ''; print "**City=$city** - Url=**$url**\n"; }