#!/opt/bin/perl use CGI; use LWP::Simple; $cgiobject=new CGI; $cgiobject->use_named_parameters; print $cgiobject->header; #read in template page $templateFile="smallville2.html"; open(INFILE,"<$templateFile"); @templatePage=; close(INFILE); #condense page array into one scalar variable $resultPage=join("",@templatePage); #determine current date ($sec,$min,$hour,$mday, $mon,$year,$wday,$yday,$isdst)=localtime(time); $curDay=(Sunday,Monday,Tuesday,Wednesday, Thursday,Friday,Saturday)[$wday]; $curMonth=(January,February,March,April, May,June,July,August,September, October,November,December)[$mon]; $liveDate="$curDay, $curMonth $mday, ".($year+1900); #search-and-replace on date $resultPage=~s//$liveDate/g; #set URL to weather web page $weatherURL="http://www.wunderground.com/cgi-bin/findweather/getForecast?query=14850"; #retrieve this web page and grab temperature $weatherPage=get($weatherURL); if ($weatherPage=~//i) {$weatherTemp=$1; #convert C to F below $weatherTemp=int(($weatherTemp*1.8)+32); $weatherTemp.="° F" } else {$weatherTemp="N/A"} #search-and-replace on weather $resultPage=~s//$weatherTemp/g; #done, output page to browser print $resultPage;