http://www.perlmonks.org?node_id=472125


in reply to Use Parsers To Get Chunk of HTML?

I've become a big fan of HTML::TreeBuilder for this sort of thing. If I understand your question, you'd do something like:
use HTML::TreeBuilder; my $tree = HTML::TreeBuilder->new_from_content($whole_thing); $tree->elementify(); my $good_chunk = $tree->look_down("_tag","div","id","good_chunk"); my $links_ref = $good_chunk->extract_links; my $good_chunk_html = $good_chunk->as_HTML;