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


in reply to get data from xpath

A few problems:

The following works:

use 5.010; use strict; use warnings; use HTML::TreeBuilder::XPath; my $url = "http://www.youtube.com/results?search_query=run+flo+rida"; my $tree = HTML::TreeBuilder::XPath->new_from_url($url); my $xpath = '(//*[@id="search-results"]/li)[1]/div[2]/h3/a/@href'; my @nodes = $tree->findnodes($xpath); say $_->getValue for @nodes;
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name