我的脚本中出现此错误,但似乎所有内容都按顺序排列:
Undefined subroutine& WWW :: Curl :: Form :: curl_formaddfile caclled at /home/script.pm 107行
107行左右的行看起来像这样:my $curlf = WWW::Curl::Form->new;
$curlf->curl_formaddfile($nfo, 'nfo', "multipart/form-data"); #107 line
$curlf->curl_formaddfile($torrent, 'file', "multipart/form-data");
$curlf->curl_formadd("name", $name);
$curlf->curl_formadd("type", $category);
$curlf->curl_formadd("descr", $$descr_txt);
$curlf->curl_formadd("anonymous", "1");
$curlf->curl_formadd("samehash", "1");
my $curl = new WWW::Curl::Easy;
my $response_details;
# windows check
if($os eq "windows"){
$curl->setopt(CURLOPT_WRITEFUNCTION, \&curl_write_data);
}else{
open (my $response_details_raw, ">", \$response_details);
$curl->setopt(CURLOPT_WRITEDATA,$response_details_raw);
}
my @curl_headers=('Expect:');
$curl->setopt(CURLOPT_HTTPHEADER, \@curl_headers);
$curl->setopt(CURLOPT_FOLLOWLOCATION, 1);
$curl->setopt(CURLOPT_RETURNTRANSFER, 1);
$curl->setopt(CURLOPT_SSL_VERIFYPEER, 1);
$curl->setopt(CURLOPT_SSL_VERIFYHOST, 1);
$curl->setopt(CURLOPT_TIMEOUT, 60);
$curl->setopt(CURLOPT_VERBOSE, 0);
$curl->setopt(CURLOPT_COOKIE, $cookie_glabella);
$curl->setopt(CURLOPT_REFERER, $upload_referer);
$curl->setopt(CURLOPT_HTTPPOST, $curlf);
$ nfo打印为/home/file.nfo
之后转到WWW :: Curl :: Easy并且它不起作用,因为它无法从此数据发出POST。 可能是什么问题呢?
答案 0 :(得分:1)
对于doc,方法curl_formaddfile
列在Compatibility
部分(Seems to be working.
)中。
也许你有一个更新的模块,所以你应该使用方法formaddfile
而不是
请参阅以下文档中的示例:
use WWW::Curl::Form;
my $curlf = WWW::Curl::Form->new;
$curlf->formaddfile($filename, 'attachment', "multipart/form-data");
$curlf->formadd("FIELDNAME", "VALUE");
$curl->setopt(CURLOPT_HTTPPOST, $curlf);