First, this *is* your code, and you're not checking whether the file opened successfully for read. Second, why are you breaking encapsulation by modifying the innards of the object?

Also, where are you getting the examples for calling setopt()? Everything I've found takes a reference, which you're not passing in.

Here's an example from Net::Curl::Easy:

$self->setopt( CURLOPT_FILE, \$self->{body} ); $self->setopt( CURLOPT_HEADERDATA, \$self->{head} );

I don't see any direct use examples for CURLOPT_READDATA.

I'm not in a position to test at the moment, so this is just a very wild guess, but first, ensure you handle opens correctly, then try the code as-is. If it still fails, try changing $lwpcurl->{agent}->setopt( CURLOPT_READDATA, $fh ); to $lwpcurl->{agent}->setopt( CURLOPT_FILE, $fh );. If that still doesn't work, try <c>$lwpcurl->{agent}->setopt( CURLOPT_FILE, \$fh );. All that said, I really, really don't think that modifying the agent like that was intended by the developers (I could be wrong though).

Can you please post a link to where you're taking your examples from, or what you're basing your code on?


In reply to Re^3: undefined value as filehandle from Curl.pm by stevieb
in thread undefined value as filehandle from Curl.pm by wanderedinn

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.