{
package Example;
use HTML::Parser;
# plain text substitution for those tags that need it:
my %tagtext = ( p => "\n\n", br => "\n", img => " ");
@Example::ISA=qw(HTML::Parser);
sub text {
my($self, $text) = @_;
$self->{TEXT}.=$text;
}
sub start {
my($self, $tag, $attr, $attrseq, $origtext) = @_;
defined(my $text = $tagtext{$tag}) or return;
$self->{TEXT} .= $text;
}
}
use LWP::Simple;
$content = get("http://www.yahoo.com");
my $parser = Example->new();
$parser->parse($content);
print $parser->{TEXT};