1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
my $url = "https://metacpan.org/pod/CGI"; my $ua = LWP::UserAgent->new; my $response = $ua->get($url); if (not $response->is_success) { die "Error fetching url $url\n $response->status_line \n"; } my $tree= HTML::TreeBuilder::XPath->new; $tree->parse($response->decoded_content); my $version = $tree->findvalue( '//a[@class="release-name"]'); if($version =~ /(\d+\.?\d+)/){ print "VERSION: ".$1; } $tree->delete;