snookmz has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks.

Short question. I am getting unwanted output from a module that I'm using WWW::Curl::new. i.e. It's printing information to STDOUT when run in the CGI and doesn't appear to give me an option to turn that output off.

My question is: Does anyone know of a way of capturing STDOUT when a third party module spits out unwanted information? And, does anyone know of a way to turn off the information that is spit out of WWW::Curl::new?

Here is a sample of the WWW::Curl::new code that I'm using. It is not a full working example as you'll need a cURL server to test it on, and I'm unable to allow access to my server.

my ($headers, $body) = ('',''); use WWW::Curl::easy; my $curl = WWW::Curl::easy->new(); my $CURLcode = $curl->setopt(CURLOPT_WRITEFUNCTION, \&callback); $CURLcode = WWW::Curl::easy::setopt($curl, CURLOPT_URL, $broker_ur +l); $CURLcode .= WWW::Curl::easy::setopt($curl, CURLOPT_HEADER,\$heade +rs); $CURLcode .= WWW::Curl::easy::setopt($curl, CURLOPT_POSTFIELDS, $p +ost_vars); $CURLcode .= WWW::Curl::easy::perform($curl); WWW::Curl::easy::cleanup($curl);


The callback() sub references above:
sub callback { my ($data,$pointer)=@_; $params{'data'} .= $data; return length($data); }


This is the unwanted information that is spit out:
HTTP/1.1 200 OK Date: Mon, 14 Mar 2005 01:42:55 GMT Server: Apache/2.0.40 (Red Hat Linux) Accept-Ranges: bytes X-Powered-By: PHP/4.2.2 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=ISO-8859-1


Any help is appreciated, Cheers.

Replies are listed 'Best First'.
Re: Unwanted output to STDOUT in WWW::Curl::new
by zentara (Cardinal) on Mar 14, 2005 at 12:35 UTC
    I can sympathize with your problem. I spent hours toying around with all those CURLOPTs. A thing you might try, is find one of the sample scripts (either in C or PhP) that does what you want, and see what it does. Somethings you might try:
    $curl->setopt(CURLOPT_VERBOSE, 0); $curl->setopt(CURLOPT_MUTE, 1); $curl->setopt(CURLOPT_HEADER, 0);
    P.S. LWP is alot easier to use. :-)

    I'm not really a human, but I play one on earth. flash japh
      Thanks for your input. Certainly a good idea to have a look at working examples in other languages. I'll also take a look at LWP, and see if I can accomplish the same task with it.

      Thanks for your reply zentara :)

      Update:
      After much wrestling with WWW::Curl::new and it's , in my opinion, difficult and unclear documentation, I have finally taken zentra's sterling advice and used LWP instead. Specifically LWP::UserAgent. What a big difference! Much easier to use, the documentation is clear, complete and gives an overview of everything that's happening.

      Thanks again zentra :)