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


In reply to WWW::Curl code works on one server not another. by kernal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.