pip has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); open(W, "weather.js"); @lines = <W>; close(W); $out = join('', @lines); if (scalar(@lines) < 3 or -M "weather.js" > 0.25) { use LWP::UserAgent; $ua = LWP::UserAgent->new(); $ua->timeout(60); $request = HTTP::Request->new('GET', 'http://www.bom.gov.au/cgi-bin/wr +ap_fwo.pl?IDS10034.txt'); $res = $ua->request($request); if ($res->is_error) { $str = $res->message; } else { $str = $res->content; } $str =~ s/^.*IDS1003401//s; $str =~ s/HEADLINE.*?$//s; if ($str =~ /:\s+(.*?)\n\n/s) { $adeldesc = $1; $adeldesc =~ s/\n//g; } if ($str =~ /Adelaide City\s+(.*?)\s+Max\s+(\d+)/s) { $adelmax = $2; } if ($str =~ /Noarlunga\s+(.*?)\s+Max\s+(\d+)/s) { $norlmax = $2; } $out =<<EOF; var adeldesc = "$adeldesc"; var adelmax = "$adelmax"; var norlmax = "$norlmax"; EOF open(W, ">weather.js"); print W $out; close(W); } print <<EOF; Content-Type: text/x-javascript Pragma: no-cache Cache-Control: no-cache Expires: -1 $out EOF
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: weather script not working
by Vautrin (Hermit) on Feb 13, 2004 at 02:21 UTC | |
by Anonymous Monk on Feb 14, 2004 at 10:41 UTC | |
|
Re: weather script not working
by Abigail-II (Bishop) on Feb 13, 2004 at 00:06 UTC | |
by Anonymous Monk on Feb 14, 2004 at 10:34 UTC | |
|
Re: weather script not working
by hossman (Prior) on Feb 13, 2004 at 19:02 UTC | |
by Anonymous Monk on Feb 14, 2004 at 10:49 UTC |