in reply to Re^2: How to extract untouched content of html tag with HTML::Parser
in thread How to extract untouched content of html tag with HTML::Parser

That depends what you mean by later. Perhaps something like the following would work for you?

sub start_handler { my $self = shift; my $tagname = shift; my $attr = shift; my $text = shift; my $variable = ''; return unless ( $tagname eq 'div' and $attr->{id} eq 'body' ); $self->handler( start => sub { $variable .= shift }, "text" ); $self->handler( text => sub { $variable .= shift }, "text" ); $self->handler(end => sub { my ($endtagname, $self, $text) = @_; if($endtagname eq $tagname) { later($variable); $self->eof; } else { $variable .= $text; } }, "tagname,self,text"); } sub later { my ($variable) = @_; ## do something with $variable }
  • Comment on Re^3: How to extract untouched content of html tag with HTML::Parser
  • Download Code