cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: perl module curl::easy

From: Cris Bailiff <c.bailiff_at_awayweb.com>
Date: Thu, 31 Jan 2002 17:27:48 +1100

Just as in C, if you want libcurl output to go to somewhere other than a file
descriptor, you need to provide a CURLOPT_WRITEFUNCTION as a callback that will
be called with each chunk of downloaded data. The function can do anything it
likes with the data, including save it in a string or array. Daniel created a
simple example already:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/curl/perl/examples/basicfirst.pl?rev=HEAD&content-type=text/vnd.viewcvs-markup

You can also look at example t/03body-callback.t in the module directory (one of
the test scripts) which does basically the same thing.

Georg added an 'internal' generic callback (in the XS layer) which collects the
callback data into a perl scalar (string) variable - the option is called
'USE_INTERNAL_VARS' - this probably does what you want as well, but I haven't
tried it, so I can't say where the data goes...

Cris

David Perry wrote:
>
> I've looked through the docs and most everything I see points the body of
> the received html doc to a file. I would like to read it into an array so
> I can operate on individual lines. Can someone point me to an example of
> stepping through lines of an html file, array based?
>
> Thanks
>
> --David Perry
Received on 2002-01-31