curl-library
RE: CURLOPT_FILE question
Date: Wed, 17 Dec 2003 18:50:37 -0500
It doesn't seem as though you mimicked that example all that well. You
haven't set the CURLOPT_WRITEDATA settings. I'm looking on that page and I
see:
sub chunk { my ($data,$pointer)=@_; ...do something...; return length($data)
}
# call the above routine from curl:
$code = $curl->setopt(CURLOPT_WRITEFUNCTION, \&chunk );
$code = $curl->setopt(CURLOPT_FILE, \$variable );
$curl->perform();
Your sample doesn't have the write function stuff which is what is causing
your problem. CURLOPT_FILE expects a FILE *, you're not giving it a FILE *,
you're giving it a reference, which I guess Perl translates to a pointer.
Since you want to give it something other than a file stream, you must
define your own write function, one that writes to a variable rather than to
a file.
Dominick Meglio
-----Original Message-----
From: Kenneth.Quan_at_wellsfargo.com
To: curl-library_at_lists.sourceforge.net
Sent: 12/17/03 5:33 PM
Subject: CURLOPT_FILE question
Using curl 7.10.5 (sparc-sun-solaris2.8)
Running a simple test code below, I get an error with Bad filehandle:
at
./curl.pl line 7.
I basically mimicked the example show here:
http://search.cpan.org/~crisb/WWW-Curl-2.0/easy.pm.in
I mainly just want to capture output into a string to perform simple
pattern
matching, so I basically don't want any tmp files floating around once
pattern matching is over.
Thanks
#!/usr/local/bin/perl
use WWW::Curl::easy;
$body = "";
my $curl = WWW::Curl::easy->new();
$curl->setopt(CURLOPT_VERBOSE, TRUE);
$curl->setopt(CURLOPT_URL, "http://yahoo.com");
$curl->setopt(CURLOPT_FILE, \$body);
my $ret=$curl->perform();
print $body;
exit;
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for
IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys
admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Received on 2003-12-18