in reply to Re^6: weather fetching script
in thread weather fetching script
Okay, this is a fairly dirty hack - but it should do the trick. You need to change the for loop that extracts the information from the @lines array to look like this:
for my $line (@lines) { if ($line =~ /^Forecast for/ && !$adeldesc) { while ($lines[$cnt++] ne "") { $adeldesc .= " $lines[$cnt]"; } } if ($line =~ /^([\w\s]+):.*?Max\s+(\d+)/) { $cities{$1}{max} = $2; } $cnt++; }
The change is the insertion of the while loop at the top, which basically says: "If the next line is not blank, append its contents to the $desc variable. (There always appears to be a blank line before the precis forecast).
This gives me the following output:
var adeldesc = " Fine, with high cloud. Cool to mild with light to mod +erate northeast to northwest winds. " var mtbkmax = "15" var noarmax = "16" var adelmax = "17" var elizmax = "17"
Cheers,
Darren :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: weather fetching script
by pip (Novice) on Jul 25, 2006 at 07:36 UTC |