html - Can't call method "setValue" on an undefined value - perl -
use strict; use warnings; use utf8; use 5.010; use html::html5::parser; open (file, '<links.txt') ; @lines = <file>; $i; $a = $lines[$i]; $xml = html::html5::parser->load_html(location => $a) ;
got error: "can't call method "setvalue" on undefined value @ c:/dwimperl/perl/site/lib/ html/html5/parser/tagsoupparser.pm line 2946"
i've tried insert if , define value first doesn't work.
i'm @ beginning of learning perl, here me this?
use strict; use warnings; use utf8; use 5.010; use html::html5::parser; use try::tiny; open (my $file, '<', 'links.txt') ; @lines = <$file>; $i = 0; foreach $a (@lines) { $xml = try { html::html5::parser->load_html(location => $a) } catch { warn "bad line [$i][$a]"; warn "actual error: $_"; }; $i++; }
i've cleaned code best guess how it's supposed structured, , added try/catch block (using try::tiny
) demonstrate method of identifying problem lines.
you need identify input causing problem before can diagnose problem.
Comments
Post a Comment