#!/usr/bin/perl
use LWP::Simple;

print "Enter your zip code: ";
$zip = <>;
chomp $zip;

$myKey = "f61688e49d777e1356931c8f411d3228";
$url = "http://api.openweathermap.org/data/2.5/forecast?mode=xml&zip=$zip,us&APPID=$myKey";
$file  = get $url;
#print $file;

if ($file =~ /sun rise="([^"]+)" set="([^"]+)/) {
	print "Sun rise is at $1 and set is at $2\n";
}

@tags = split(/</,$file) ;
foreach $tag (@tags) {
	if ($tag =~/^clouds value="([^"]+)"/ && $cloud eq "") {
		$cloud = $1;
		print "Clouds are $cloud\n";
	}
	if ($tag =~ /^windSpeed mps="[^"]+" name="([^"]+)"/ && $wind eq "") {
		$wind = $1;
		print "Wind is $wind\n";
	}
}