in reply to Downloading a auto-generated file.

All you need is LWP::Simple,
use strict; my $url = 'http://www.google.com/finance/historical?q=NASDAQ:FFIV&outp +ut=csv'; my $file = 'data.csv'; use LWP::Simple; my $content = get($url); die "Couldn't get it!" unless defined $content; open my $fh, '>', $file or die "Can't open file $file: $!"; print $fh $content; close $fh;
- Miller

Replies are listed 'Best First'.
Re^2: Downloading a auto-generated file.
by Matthew.S (Initiate) on Jan 30, 2011 at 19:24 UTC

    Thank you for this!!!

    This is simple and beautiful!!!

    Matthew.

Re^2: Downloading a auto-generated file.
by ww (Archbishop) on Jan 28, 2011 at 01:58 UTC

    It might be clearer to use FH instead of $fh...

    open FH, '>', $file or die "Can't open file $file: $!"; print FH $content; close FH;

      Clearer for those accustomed to old school Perl and in a very small context maybe.

      The preferred convention currently is to use a lexical file handle as shown by wind which is safer than the old school bare word file handle and, with an appropriate name, is at least as clear.

      True laziness is hard work
        ++ GrandFather; you are, of course, correct... and I should not assert my taste as a fact.

        However it seems to me that the current convention has some serious deficiencies unless, as you suggest, the variable has a crystal-clear name or is documented in a comment. Otherwise, it runs the risk of appearing to spring forth from nowhere, whereas the bareword usage has sufficient precedent to avoid any lack of clarity.

        For a case that seems plausible to me, suppose wind's lines 6-8 were separated from lines 10-12 by multiple lines of code to process the page content; to limit to the minimum desired what's actually written to file. Alternately (particularly relevant here), consider the possibility that one wished to use inline code (probably not the best technique, but one that's often seen) to deal with encoding (the first few bytes appear to be non-ASCII) or to format the comma-separated-values across tab-spaced columns for printing.

        JM$.02W