cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Problem with right data to file using WWW::Curl

From: Swati Vakharia <swativ_at_gmail.com>
Date: Mon, 21 Jun 2004 15:03:01 -0700

actually ..nevermind...was doing CURLOPT_FILE_ instead of CURLOPT_FILE
(note the trailing _ which was a typo)

On Mon, 21 Jun 2004 10:39:34 -0700, Swati Vakharia <swativ_at_gmail.com> wrote:
>
> Hi. I'm trying to download a file using the WWW::Curl::easy perl
> module. I receive the data but it never gets written to my file. Any
> help would be appreciated. Here's my code:
>
> #!/usr/bin/perl
>
> use strict;
> no strict 'subs';
> use WWW::Curl::easy;
>
> use IO::File;
>
> my $url = "ftp://nebulous.cobaltgroup.com/NOTES";
> my $body="";
>
> sub chunk { my ($data,$pointer)=@_; ${$pointer}.=$data; return length($data) }
>
> #init curl session
> my $curl = WWW::Curl::easy->new();
>
> my $code = $curl->setopt(CURLOPT_TIMEOUT, 30);
> $code = $curl->setopt(CURLOPT_URL, $url);
>
> my $fh = new IO::File("test2.txt", 'w');
>
> $code = $curl->setopt(CURLOPT_WRITEFUNCTION, \&chunk );
> $code = $curl->setopt(CURLOPT_FILE_,\$fh);
> print "MY CODE: [$code]";
>
> $curl->perform();
> my $bytes=$curl->getinfo(CURLINFO_SIZE_DOWNLOAD);
>
> print" bytes: $bytes\n";
>
Received on 2004-06-22