in reply to Re^4: weather fetching script
in thread weather fetching script

"..get the description being shown in "quotation marks" ?"

Oh, I hadn't noticed that... you need to change line 46 to read:

my $out = qq(var adeldesc = "$adeldesc"\n);
The use of 'qq' allows us to use double-quotes within the string, and also ensures that the variables are correctly interpolated.

"how do I get the script to write to /home/aml33704/public_html/"

Well, you simply change the destination in the open statement to include the full path to the file. I'd do something like this:

my $outfile = '/home/aml33704/public_html/weather.js';
..and then:
open W, ">", $outfile or die "Could not open $outfile for writing:$!\n +";

Cheers,
Darren :)

(By the way, which address do I mail my invoice to?) ;)

Replies are listed 'Best First'.
Re^6: weather fetching script
by pip (Novice) on Jul 14, 2006 at 07:29 UTC
    You're the man Darren, Thanks a bunch, everything working fine!...this script really bugged me. I am happy to shout you a drink when you're in Adelaide. I would also be happy to paypal some appreciation for your efforts. cheers, pip
Re^6: weather fetching script
by pip (Novice) on Jul 25, 2006 at 02:10 UTC
    Hi Darren, I was just wondering ...when the script outputs its description, only the 1st line of the sentence is displayed, even so the bom txt (sometimes) contains another line. Example: Script output: Fine and cool to mild day with increasing high cloud. Light winds, chiefly BOM txt output: Fine and cool to mild day with increasing high cloud. Light winds, chiefly northeast to northwest. Question: Is it possible to display all of the description, regardles if 1 or 2 sentences, and have 'precis' act as the 'full stop'of the description? cheers, pip
      This is Perl - easy things are easy, and difficult things are possible ;)

      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 :)

        Thanks Darren, That did the trick ...thanks so much! cheers, pip