found this perlscript at Mac OSX Hints
#!/usr/bin/perl
#
# getWeather--a script to get weather information from Weather.com
# by Mark T. Tomczak, 2002
#
$ZIPCODE=15213;
if($#ARGV == 0)
{
$ZIPCODE=$ARGV[0];
$ZIPCODE =~m/ddddd/gi;
if(length($ZIPCODE) != 5)
{
print "Invalid zipcode. Please enter only a five-digit zipcode.n";
exit;
}
}
open(INPUT, "wget http://www.weather.com/weather/local/$ZIPCODE -q -O-|");
@stream=<INPUT>;
close(INPUT);
$stream=join(" ", @stream);
#extract the forecast
if($stream=~ m/<!-- insert forecast text -->.*</td>/gi)
{
$forecast=$&;
$forecast =~ s/<!-- insert forecast text -->//;
$forecast =~ s/</td>//;
}
else
{
$forecast= "... umm... I'm not sure...";
}
#extract the temperature
if($stream=~ m/<!-- insert current temp -->.*?°F/gi)
{
$temp=$&;
$temp =~ s/<!-- insert current temp -->//;
$temp =~ s/°F//;
}
else
{
$temp= "... umm... I'm not sure...";
}
# pick up on today's forecast
($stream=~m/<!-- insert load change day/date here -->/) || die "Couldn't parse weather information.";
$stream=$';
$stream=~s/n//gi;
$daycast=$stream;
$daycast=~m/<TD CLASS="dataText" ALIGN="LEFT">/gi || die "Couldn't parse weather information.";
$daycast=$';
$daycast=~s/</TD>.*//gi;
#trim whitespace from the variable
$daycast=~s/^s*//gi;
$daycast=~s/s*$//gi;
#pick up today's high
$daytemps=$stream;
($daytemps=~/ /gi) || die "Couldn't parse weather information";
$stream=$';
$dayhigh=$stream;
$dayhigh =~ s/</TD>.*//gi;
$dayhigh =~ s/°F.*//gi;
$dayhigh=~s/^s*//gi;
$dayhigh=~s/s*$//gi;
#pick up today's low
($daytemps=~m/ /gi) || die "Couldn't parse weather information";
$stream=$;
$daylow=$stream;
$daylow =~ s/</TD>.*//gi;
$daylow =~ s/°F.*//gi;
$daylow=~s/^s*//gi;
$daylow=~s/s*$//gi;
#Output the results.
$output="The current weather is $forecast, and the current temperature is $temp.nThe forcast for today is $daycast.";
if(length($dayhigh) !=0)
{
$output=$output."nThe high is $dayhigh.";
}
if(length($daylow) !=0)
{
$output=$output."nThe low is $daylow.";
}
print "$outputn";
Its saved to my home partition (cleverly titled “Home”)
saved with SimpleText under the name “getWeather”
In the Terminal I type…
% cd /Volumes/Home
% chmod 755 getWeather
% rehash
% ./getWeather
then it spits this at me…
Couldnt parse weather information. at ./getWeather line 44.
help? anyone? please!
not really important that i get this working, but it looks like fun… ![]()




11” MacBook Air 1.6GHz dual-core Intel Core i5: $829.00 Delivered
Samsung S22B300B 21.5” LED Backlit LCD Monitor: $129.99 Delivered
Canon imageCLASS Monochrome Multifunction Laser Printer: $129.99 Delivered
