in reply to searching for one or more instances of text between tags

Here's a way to do it using HTML::TreeBuilder::XPath
use HTML::TreeBuilder::XPath; my $html = '<div><ul class="test"> <li><a href="/www/?category=Earth">earth_text</a></li> <li><a href="/www/?category=Space">space_text</a></li></div>'; my $tree = HTML::TreeBuilder::XPath->new; $tree->parse($html); $tree->eof; my @values = $tree->findvalues('//li/a'); print "$_\n" for @values;
Or if you need more specific selection, or other info returned
my @links = $tree->findnodes('//ul[@class="test"]/li/a') ; for my $link (@links) { print $link->attr('href'), "\n"; print $link->as_text, "\n"; }