views:

67

answers:

2

Hi. I want to use following script:

use FileHandle;
use WWW::Curl::Easy;
use WWW::Curl::Form;

my $file, my $curl, my $curlf, my $return, my $minified;

$file = new FileHandle();

$curl = new WWW::Curl::Easy();
$curl->setopt(CURLOPT_URL, "http://closure-compiler.appspot.com/compile");
$curlf = new WWW::Curl::Form();
$curlf->formadd('output_format',      'text');
$curlf->formadd('output_info',        'compiled_code');
$curlf->formadd('compilation_level',  'ADVANCED_OPTIMIZATIONS');
$curlf->formaddfile($name, 'js_code', 'multipart/form-data');
$curl->setopt(CURLOPT_HTTPPOST, $curlf);

$file->open(\$minified, ">");
$curl->setopt(CURLOPT_WRITEDATA, $file);
$return = $curl->perform();

Following error is thrown:

Can't locate object method "formadd" via package "WWW::Curl::Form" at ./minifyjs.pl ....

WHY??? The WWW::Curl module is installed properly, I used package libwww-curl-perl under Debian/Ubuntu.

Can anyone help me please?

+1  A: 

Check out WWW::Mechanize. It has a lot of nice form methods.

Matt H
+4  A: 

Whoops.

Looks like this commit broke formadd. The XS sub doesn't match the PREFIX = curl_form_ declaration (as it's named curl_formadd), so perl doesn't know how to map the Perl version of the method back to XS.

4.12 was the first release that tried to support WWW::Curl::Form, looks like it didn't work after all. Not sure how I've missed this one. I should probably note it here that WWW::Curl::Form support wasn't exactly a high priority TODO item on my list, due to the existence of various high quality form handling modules on CPAN. I've only accepted the patch for the sake of feature completeness. You're encouraged to use those modules for managing form content. The standard WWW::Curl use case statement applies.

I released 4.13 to fix this issue. Good catch!

szbalint