Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl # use warning; use CGI; use CGI::Pretty; use strict; use lib qw(/home/001/d/da/dale81/LWP/lib/perl5/site_perl/ /home/001/d/da/dale81/LWP/lib/perl5/site_perl/LWP/); use LWP::Simple; my $fdata = CGI->new(); print $fdata->header; print $fdata->start_html('Weather'); my $zip = 75252; my $url1 = 'http://www.wunderground.com/cgi-bin/findweather/getForecas +t?query='; my $url = $url1.$zip; my $response =get( $url ); my $day01; my $day02; my $day03; my $day04; my $day05; my $fTemp; my $cTemp; #extract 5-day outlook if($response=~/<th(.+)>([a-zA-Z]+)<\/th>(\s)<th(.+)>([a-zA-Z]+)<\/th>( +\s)<th(.+)>([a-zA-Z]+)<\/th>(\s)<th(.+)>([a-zA-Z]+)<\/th>(\s)<th vali +gn=middle class=smalltable width="20%" bgcolor=#DDDDDD>([a-zA-Z]+)<\/ +th>/i) { $day01=$2; $day02=$5; $day03=$8; $day04=$11; $day05=$13; } #output days as headings print $fdata->h1($day01); print br; print $fdata->h1($day02); print br; print $fdata->h1($day03); print br; print $fdata->h1($day04); print br; print $fdata->h1($day05); print br; #extract temp data if($response=~/<nobr><b>([0-9]+)<\/b> °\;F<\/nobr>(\s+)\/(\s+ +)<nobr><b>([0-9]+)<\/b> \;°C<\/nobr>/i) { $fTemp=$1; $cTemp=$4; } #output temperature print "Temperature F=", $fTemp; print br; print "Temperature C=", $cTemp; print br; print $fdata->end_html;
2004-12-07 Janitored by Arunbear - added readmore tags, as per Monastery guidelines
|
|---|