Personally, I like japhy's answer, but since you are
wanting to know how to do it with HTML::Parser, here is
yet another way.
use strict;
use LWP::Simple;
use HTML::Parser;
# get the content of the web page
my $content = get("http://www.google.com/");
# instaniate a new parser and let it crunch our data
my @lines;
my $parser = new MyParser;
$parser->parse($content);
{
package MyParser;
use base qw(HTML::Parser);
# this method supplies the text, no tags :)
sub text {
my ($self, $origtext) = @_;
print $origtext, "\n";
}
}
Unfortunately, this is the OLD way to use HTML::Parser,
I haven't learned the new way yet (bad jeffa!). But this
should get you going.
UPDATE:
If you want to store the contents in a variable, just
add
my $stripped_html; # or whatever you wanna call it
Then, inside the text subroutine replace the print line
with:
$stripped_html .= $origtext;
I would recommend using an array instead, however:
my @stripped_html;
#and inside &text
push(@stripped_html, $origtext);
UPDATE: UPDATE:
just do what merlyn says :)
Jeff
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)
|