Bug-fix in lib/LWP/Protocol.pm

Rujith de Silva (Rujith_S_DeSilva@child.prodigy.cs.cmu.edu)
Fri, 15 Dec 1995 19:33:35 -0500


-----BEGIN PGP SIGNED MESSAGE-----

Here's a bug-fix for:
                          libwww-perl version 5b6

I hope this is the right mailing list to send these.

In lib/LWP/Protocol.pm:

sub collect
{
    my ($self, $arg, $response, $collector) = @_;
    my $content;
    if (! defined $arg) {
        # scalar
        ...
    }
    elsif (!defined ref($arg)) {   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        # filename
        open(OUT, ">$arg") ...
        ...
    }
    elsif (ref($arg) eq 'CODE') {
        # read into callback
        ...
}

So $arg can be of various formats.  In particular, if it's a simple string
containing a filename, the response is written to that file.  This is
tested by the marked line using:

    ! (defined ref($arg))

However, ref ($arg) can never be undefined; it's supposed to return a FALSE
value on a scalar, as the documentation says:

ref EXPR 
     Returns a TRUE value if EXPR is a reference, FALSE otherwise. ...

So the test should actually be:

    elsif (! ref($arg)) {

Later,
Rujith.

Rujith de Silva.  1-(412) 268-3620.  desilva+@cmu.edu
http://www.cs.cmu.edu/~desilva/
PGP public key available by finger.

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBMNIT24kharavxuYRAQGgzgP9EcFXm9xNq1x7hMQgx8qQp1MTXo+VCxmf
u6+0upOe94/0bml8M+VEhOhTLthBwwLSE8ZGMXNUkGc3+94NyvSKdlUTn2Xb3DXU
qK1HEciRBTmbGgOOl7lWRaNaUOxXNrkeztAXJ+kzBj5LMRJNn3hyShnXTGW7N0nh
WBrzWuEpmYk=
=NVv5
-----END PGP SIGNATURE-----