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"); }
In reply to why this couldn't work? by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |