munzer
asked on
PERL and LIBCURL
Does anyone have a simpe PERL script that calls libcurl command and print the output.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In order to access libcurl from Perl, you need to install an interface package, such as WWW::Curl, which is required by the above example. Take a look at the following page:
http://curl.haxx.se/libcurl/perl/
______________
Nayer Naguib
http://curl.haxx.se/libcurl/perl/
______________
Nayer Naguib
ASKER
I did install it before I tried running the script.
The errors above indicate that the Perl interpreter was indeed able to locate the file easy.pm under the path WWW/Curl, because otherwise the following error would have been displayed:
Can't locate WWW/Curl/easy.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib .) at example.pl line 4.
However, the errors also indicate that the file easy.pm does not export libcurl function names, which is why the interpreter thinks that function names in your file are "barewords" and not functions (barewords are strings without surrounding single quotes). You need to follow the installation instructions on the page posted above. Take a look at the following page and compare the file easy.pm to WWW/Curl/easy.pm on your local file system:
http://www.koders.com/perl/fid50DCD11E38F3A37C3437E8F713DFEA2349C99D7A.aspx
It will give you an indication of how the file should look like.
______________
Nayer Naguib
Can't locate WWW/Curl/easy.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib .) at example.pl line 4.
However, the errors also indicate that the file easy.pm does not export libcurl function names, which is why the interpreter thinks that function names in your file are "barewords" and not functions (barewords are strings without surrounding single quotes). You need to follow the installation instructions on the page posted above. Take a look at the following page and compare the file easy.pm to WWW/Curl/easy.pm on your local file system:
http://www.koders.com/perl/fid50DCD11E38F3A37C3437E8F713DFEA2349C99D7A.aspx
It will give you an indication of how the file should look like.
______________
Nayer Naguib
I wasted an hour on this tonight - solution was to change use WWW:Curl:easy to WWW:Curl:Easy (uppercase Easy), and then it worked. Must be a bug in Perl or something that it found the .pm modules, but didn't assign the namespace...
-Wayne
-Wayne
ASKER
I get this:
Bareword "CURLOPT_HEADERFUNCTION" not allowed while "strict subs" in use at test4.pl line 21.
Bareword "CURLOPT_WRITEFUNCTION" not allowed while "strict subs" in use at test4.pl line 22.
Bareword "CURLOPT_HTTPHEADER" not allowed while "strict subs" in use at test4.pl line 27.
Bareword "CURLOPT_FILE" not allowed while "strict subs" in use at test4.pl line 28.
Bareword "CURLOPT_URL" not allowed while "strict subs" in use at test4.pl line 32.
Execution of test4.pl aborted due to compilation errors.