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

Hi Darren, Thanks for the mod for the script, temps now show up. Sorry for being a pain...but how can I firstly: get the description being shown in "quotation marks" ? (html page shows errors if it doesn't have them)and secondarily: how do I get the script to write to /home/aml33704/public_html/ ? (Can't get the results to show unless outside cgi-bin) I am very grateful for your help! cheers, pip

Replies are listed 'Best First'.
Re^5: weather fetching script
by McDarren (Abbot) on Jul 14, 2006 at 06:16 UTC
    "..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?) ;)

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