I find using CSS selectors easier, in which case you stick with HTML::TreeBuilder::XPath and throw in HTML::Selector::XPath. Then:
my $selector = "#fiddlesticks li a";
my $tree = HTML::TreeBuilder::XPath->new();
my $xpath = HTML::Selector::XPath->new($selector)->to_xpath;
my @nodes = $tree->findnodes($xpath);
for my $n (@nodes) {
print "Fiddlesticks Link: ", $n->attr('href'), "\n";
}
The zeroeth step in writing a module is to make sure that there isn't already a decent one in CPAN. (-- Pod::Simple::Subclassing)