#!/usr/bin/perl -w use strict; use LWP::Simple; use HTTP::Request; #Name your city, village, carton box my $city = "My City"; #Text to appear in above weatherreport my $wthrtext = "Current Weather in $city:"; # Your very own ICAO location. See http://weather.noaa.gov for more info... my $weathericao = "EHAM.TXT"; # Create yer user agent object use LWP::UserAgent; my $ua = new LWP::UserAgent; $ua->agent( "WeatherBot " . $ua->agent ); # Add your request ;) my $req = HTTP::Request->new( GET => "ftp://weather.noaa.gov/data/observations/metar/decoded/$weathericao" ); $req->header( Accept => "text/html, */*;q=0.1" ); # Now pass that request to the user agent and get a response back my $res = $ua->request($req); # Check the outcome of the response if ( $res->is_success ) { print "Fetched weather...\n\n"; } else { print "Nope, couldn't fetch weather...\n"; exit; } my $weather = $res->content; #Bring on the sunshine! print "$wthrtext\n\n$weather";