use strict;
use warnings;
use utf8;
use 5.010;
use HTML::HTML5::Parser;
use Try::Tiny;
open (my $FILE, '<', 'links.txt') ;
my @lines = <$FILE>;
my $i = 0;
foreach my $a (@lines) {
my $xml = try {
HTML::HTML5::Parser->load_html(location => $a)
} catch {
warn "Bad line [$i][$a]";
warn "Actual error: $_";
};
$i++;
}
I've cleaned up your code with my best guess as to how it's actually supposed to be structured, and added a try/catch block (using Try::Tiny
) to demonstrate a method of identifying your problem lines.
You need to identify what input is causing the problem before you can really diagnose the problem.