I ran into similar problems for my module WWW::Search.
  No, out-of-the-box you can not re-use an HTML::TreeBuilder object to parse
a new file.  BUT you can use the following code as a "reset". I.e. call
parse, muck with the tree, do the following four lines, and call parse
again.  This does the same as new() but without changing the store_comments,
store_pis settings, etc:

  $self->{'_head'} = $self->insert_element('head',1);
  $self->{'_pos'} = undef;  # pull it back up
  $self->{'_body'} = $self->insert_element('body',1);
  $self->{'_pos'} = undef;  # pull it back up again

  The reason you can't re-use your HTML::Element is because it's a
reference, and when the tree gets deleted, your Element gets deleted right
along with it.

 - - Martin Thurn

Reply via email to