Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
use WWW::Curl::Easy; my $curl = WWW::Curl::Easy->new; $curl->setopt(CURLOPT_HEADER,0); $curl->setopt(CURLOPT_TIMEOUT, 30); $curl->setopt(CURLOPT_FOLLOWLOCATION, 1); $curl->setopt(CURLOPT_URL, 'http://example.com'); my $response_body = ''; open(my $fileb, ">", \$response_body); $curl->setopt(CURLOPT_WRITEDATA,$fileb); my $retcode = $curl->perform; if ($retcode == 0) { print("Received response: $response_body\n"); } else { print("An error happened: $retcode ".$curl->strerror($retcode) +." ".$curl->errbuf."\n"); }
require WWW::Curl::Easy; import WWW::Curl::Easy; my $curl = WWW::Curl::Easy->new; $curl->setopt(CURLOPT_HEADER,0); $curl->setopt(CURLOPT_TIMEOUT, 30); $curl->setopt(CURLOPT_FOLLOWLOCATION, 1); $curl->setopt(CURLOPT_URL, 'http://example.com'); my $response_body = ''; open(my $fileb, ">", \$response_body); $curl->setopt(CURLOPT_WRITEDATA,$fileb); my $retcode = $curl->perform; if ($retcode == 0) { print("Received response: $response_body\n"); } else { print("An error happened: $retcode ".$curl->strerror($retcode) +." ".$curl->errbuf."\n"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why this couldn't work?
by Corion (Patriarch) on Jul 01, 2011 at 16:46 UTC | |
|
Re: why this couldn't work?
by Anonymous Monk on Jul 01, 2011 at 16:47 UTC | |
by Anonymous Monk on Jul 01, 2011 at 17:02 UTC | |
by Corion (Patriarch) on Jul 01, 2011 at 17:12 UTC | |
by Anonymous Monk on Jul 01, 2011 at 17:19 UTC | |
by chromatic (Archbishop) on Jul 01, 2011 at 17:33 UTC | |
by Anonymous Monk on Jul 01, 2011 at 17:41 UTC | |
|
Re: why this couldn't work?
by PerlAddict42 (Novice) on Mar 02, 2017 at 08:19 UTC | |
|
Re: why this couldn't work?
by Anonymous Monk on Dec 18, 2013 at 19:55 UTC |