I quote:
   If new() is called without any arguments, it will create a parser that
   uses callback methods compatible with version 2 of C<HTML::Parser>.
   See the section on "version 2 compatibility" below for details.

A HTML::Parser v2 compatable parser has handlers defined for the usual
events so the default handler does not get called.

Call new like this instead:
   my $p = HTML::Parser -> new( api_version => 3 );
or
   my $p = HTML::Parser->new( default_h => [ \&text, 'text' ] );

--
Mac :})
** I may forward private database questions to the DBI mail lists. **
----- Original Message -----
From: "Hugo Haas" <[EMAIL PROTECTED]>
To: "Michael A. Chase" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, July 07, 2000 9:06 PM
Subject: Re: HTML::Parser bug?


> On Fri, Jul 07, 2000, Michael A. Chase wrote:
> > Perhaps you could give us an example of the text you are trying to parse
> > that includes a comment that gets passed to the 'comment' event handler,
but
> > doesn't get passed to the 'default' event handler when the 'comment'
handler
> > isn't defined.
>
> Sorry, I realized that I sent my example without enough details but you
> replied before I could submit an example.
>
> > A short example script that shows the problem would also be handy.  I'd
be
> > especially interested in seeing all HTML::Parser method calls..
>
> I was running a test on an excerpt of an HTML file (this is not valid
> HTML by itself, but I did that to isolate the problem):
>
> <!-- test
> --> <a href="fdasfafdas"></a>
>
> Here's a sample script:
>
> use strict;
> require HTML::Parser;
> my $p = HTML::Parser->new;
> $p->handler(@EVENT@ => \&text, 'text');
> $p->parse_file('/tmp/foo.html');
>
> sub text() {
>   my ($t) = @_;
>   print $t . "\n";
> }
>
> With @EVENT@ being 'comment':
>
> [hugo:pts/2] larve:~> perl -w test.pl
> <!-- test
> -->
> [hugo:pts/2] larve:~>
>
> With @EVENT@ being 'default':
>
> [hugo:pts/2] larve:~> perl -w test.pl
> [hugo:pts/2] larve:~>


Reply via email to