SneakZa has asked for the wisdom of the Perl Monks concerning the following question:
my $p = HTML::Parser->new( api_version => 3 ); $p->handler( start => \&start_handler, "self,tagname,attr" ); $p->parse($content); exit; my $inner_body; sub start_handler { my $self = shift; my $tagname = shift; my $attr = shift; my $text = shift; my $inner_body; return unless ( $tagname eq 'body' ); $self->handler( start => sub { my ($text) = @_; $inner_bod +y = $inner_body. $text; }, "text" ); $self->handler( text => sub { my ($text) = @_; $inner_body = $in +ner_body. $text; }, "text" ); $self->handler( end => sub { my ($endtagname, $self, $text) = @_; if($endtagname eq $tagname) { $self->eof; } else { $inner_body = $inner_body. $text; } }, "tagname,self,text"); } print $inner_body;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: html::parse inner body html
by tangent (Parson) on May 29, 2013 at 21:44 UTC | |
by SneakZa (Initiate) on May 29, 2013 at 22:53 UTC | |
by tangent (Parson) on May 30, 2013 at 00:17 UTC |