while ( my $token = $p->get_tag( "div" ) ) { if ( $token->[1]->{'id'} eq 'good_chunk' ){ # get the entire contents of the div, as HTML, # for further parsing } }