use HTML::Parser();
# Create instance
$p = HTML::Parser->new(start_h => [\&start_rtn, 'tag'],
text_h => [\&text_rtn, 'text'],
end_h => [\&end_rtn, 'tag']);
# Start parsing
$p->parse_file('http://www.mysite.com');
sub start_rtn {
# Execute when start tag is encountered
foreach (@_) {
print "Start tag = $_\n";
}
}
sub text_rtn {
# Execute when text is encountered
foreach (@_) {
print "Text = $_\n";
}
}
sub end_rtn {
# Execute when the end tag is encountered
foreach (@_) {
print "End = $_\n";
}
}