"Sean M. Burke" <[EMAIL PROTECTED]> writes:

> At 07:47 PM 1999-12-14 -0800, Randal L. SCHWArtz wrote:
> >[...]
> >This means that installing HTML::Parser 3.0 breaks anything that
> >uses HTML::TreeBuilder, including my cute html2cgi script from my
> >Perl-WT column.
> 
> That reminds me: now that I seem (I can't quite believe it) to have a
> new TreeBuilder working quite nicely, which uses the old (pure Perl)
> HTML::Parser, I think I should release it; and then, once I'm
> happy I've got all the wrinkles out of it, maybe I'll have a hack at
> getting it working via the new Parser's callback-based interface.
> 
> Ideally, I'd like (for the time being at least) for both the
> old and new Parsers to be compatible with both the old and new
> (well, immanent) HTML-Tree.

This patch based on
http://www.netadventure.net/~sburke/temp_html_tree/TreeBuilder.pm
should make it work properly with both HTML-Parser-2.25 and
HTML-Parser-3.00.

Index: lib/HTML/TreeBuilder.pm
===================================================================
RCS file: /home/cvs/aas/perl/mods/html-tree/lib/HTML/TreeBuilder.pm,v
retrieving revision 2.7.2.1
diff -u -p -u -r2.7.2.1 TreeBuilder.pm
--- lib/HTML/TreeBuilder.pm     1999/12/15 10:26:53     2.7.2.1
+++ lib/HTML/TreeBuilder.pm     1999/12/15 10:35:58
@@ -338,7 +338,10 @@ sub new {
   $class = ref($class) || $class;
 
   my $self = HTML::Element->new('html');  # Initialize HTML::Element part
-  $self->{'_buf'} = '';  # The HTML::Parser part of us needs this
+  my $other_self = HTML::Parser->new;
+  %$self = (%$self, %$other_self);              # copy fields
+  bless $other_self, "SomethingReallyHarmless"; # unbless, avoid destructor
+  undef($other_self);
 
   # The root of the tree is special, as it has these funny attributes,
   # and gets reblessed into this class.


Multiple inheritance with when there are multiple constructors to be
called is not really perl's strongest side :-(

Sean is going to take over the HTML-Tree modules, so if he manages to
get his first release out soon, I should not have to rush out a
HTML-Parser-3.00 compatible HTML-Tree.

Regards,
Gisle

Reply via email to