On Wed Apr 08 2009 @ 10:29, Gunnar Hjalmarsson wrote:
> Telemachus wrote:
>> On Wed Apr 08 2009 @ 3:22, ANJAN PURKAYASTHA wrote:
>>> I have a file stored at a location: http://parent_dir/file
>>> Which among gazillion LWP options can I use to download and store the file
>>> on my machine?
>>
>> If you just want to grab the file, you can use LWP::Simple to grab it:
>>
>> use LWP::Simple;
>>
>> my $url = 'http://parent_dir/file';
>> my $local = '/path/to/local/file';
>> my $file = getstore($url, $local);
>
> getstore() returns the HTTP status code, so 'file' is not the most
> appropriate name of a variable to which the return value is assigned.
Gah: you're absolutely right. The last line is the coding equivalent of a
mixed metaphor: half of my brain was thinking this:
my $file = get($url);
print $file;
The other half of my brain thought:
getstore($url, $local);
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/