#!/usr/bin/perl
use HTML::TreeBuilder;
my $tree = HTML::TreeBuilder->new;
$tree->parse_file("sample.html");
foreach my $anchor ($tree->find("p")) {
print $anchor->as_text, "\n";
}
my code is not printing any output. $tree->find("p") is returning NULL.
You're not opening the file, or it's completely unparseable.
Try something like:
That way you can check which it is.
Your script worked fine when I had the following for sample.html