use HTML::Tree;
my $tree = HTML::Tree->new_from_file( "myfile.html");
my $html_object = $tree->look_down("_tag", "x", # find an x element
"y", qr/z/); # that has a y attribute matching z
####
my $text = $html_object->as_text;
####
my $html = $html_object->as_HTML;