kernal has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I have recently written some code using WWW::Curl code to access a remote server and perform an HTTPS POST operation. The problem I encounter is when I try and retrieve the responses contents. I have a dev and a production server and have found that they require different code to do this.

My code on my production server is identical to the perldoc:

my $response_body; $curl->setopt(CURLOPT_WRITEDATA,\$response_body); print STDERR $response_body;

My code on my development server I found using a google search:

my $response_body = ""; open my $response_handle, '>', \$response_body; $curl->setopt(CURLOPT_WRITEDATA,\$response_handle); print STDERR $response_body;

If I run the production code on the dev server I get the error:"Can't use an undefined value as filehandle reference at ?????????.pm line 70.". Also if I try to use the dev code on the production server I get no error and an empty string.

Both servers are running perl 5.10.1, and the same version of WWW::Curl, both are CentOS 6.6, the only difference I have found is the dev is running a 3x series kernel and the production a 2x series kernel. Any insight into why the code is behaving differently, and protecting against it would be greatly appreciated.

Thanks

Replies are listed 'Best First'.
Re: WWW::Curl code works on one server not another.
by 1nickt (Canon) on Jul 22, 2015 at 03:02 UTC

    Your problem is most likely in the libcurl binaries being different on your different OS versions. From the documentation:

    This module provides a Perl interface to libcurl. It is not intended to be a standalone module and because of this, the main libcurl documentation should be consulted for API details at http://curl.haxx.se. The documentation you're reading right now only contains the Perl specific details, some sample code and the differences between the C API and the Perl one.
    The way forward always starts with a minimal test.
Re: WWW::Curl code works on one server not another.
by GotToBTru (Prior) on Jul 22, 2015 at 12:14 UTC

    In either case, would you actually expect something other than an empty string?

    Dum Spiro Spero
      In both cases I get back a JSON string from another server which I then parse. I am just trying to find some insight into why the two servers require different code.