Rodrigo Ruiz <[EMAIL PROTECTED]> writes:

> Yesterday I updated my LWP module from version 5.75 to the current 5.8
> version. From this update, one of my scripts has stopped working.

Oops!  Sorry.

> The script creates a PUT request, specifying a subroutine as the
> content, for dynamic content retrieval. The original code does:
> 
>       my $req = HTTP::Request->new("PUT", $url, $header, $readFunc);
> 
> But now it dies with a "Not a SCALAR reference" error.

I tried to reproduce this error but it did not happen for me.  Are you
able to provide a complete little program that demonstrate this
failure.

> I have been debugging the LWP code, and I have found the following
> workaround:
> 
>       my $req = HTTP::Request->new("PUT", $url, $header, \$readFunc);
> 
> That is, pass the function reference, by reference.
> 
> Unfortunately, this change makes my script fail with older LWP versions.
> 
> My questions are:
> Is there a more elegant workaround that do not break compatibility
> with older LWP versions?

You could always do;

   .... $LWP::VERSION < 5.800 ? $readFunc : \$readFunc

but I rather fix this problem in 5.801.  A test case that reproduce
this would be very helpful.

> If not, and I put these two lines in an if-else sentence, comparing
> the $LWP::VERSION value with a "threshold" , which exact version
> should I compare to?

This change went into 5.800. I'm quite sure it must be the culprit:

|    HTTP::Message will now allow an external 'content_ref'
|    to be set.  This can for instance be used to let HTTP::Request
|    objects pick up content data from some scalar variable without
|    having to copy it.

Regards,
Gisle

Reply via email to