Re: Usage: HTML::Parser::parse(self, chunk)

Gisle Aas (gisle@activestate.com)
10 Apr 2001 10:15:57 -0700


"Matej Kovacic" <matej.kovacic@uni-lj.si> writes:

> Uncaught exception from user code:
>         Usage: HTML::Parser::parse(self, chunk) at jure.pl line ---.

[...]

> # HTTP Response Codes on Has(c)h (RFC2068)
> ###
> my %statuscode = (
> 	100   => 'Continue',
> 	101   => 'Switching Protocols',
> 	200   => 'OK',
> 	201   => 'Created',

BTW, this data is also available from the HTTP::Status module.

>     my $parser = HTML::LinkExtor->new(undef, $main::base_url);
>     $parser->parse(get($main::base_url))->eof;

The error probably shows up because get() returns nothing instead of
undef.  I think the following patch should fix the problem:

Index: lib/LWP/Simple.pm
===================================================================
RCS file: /cvsroot/libwww-perl/lwp5/lib/LWP/Simple.pm,v
retrieving revision 1.33
diff -u -p -u -r1.33 Simple.pm
--- lib/LWP/Simple.pm   2000/05/24 09:40:43     1.33
+++ lib/LWP/Simple.pm   2001/04/10 17:12:27
@@ -298,7 +298,7 @@ sub _trivial_http_get
    my $sock = IO::Socket::INET->new(PeerAddr => $host,
                                     PeerPort => $port,
                                     Proto    => 'tcp',
-                                    Timeout  => 60) || return;
+                                    Timeout  => 60) || return undef;
    $sock->autoflush;
    my $netloc = $host;
    $netloc .= ":$port" if $port != 80;

Regards,
Gisle