#!/usr/bin/perl -w use strict; use warnings; use Encode; use encoding "utf8"; use XML::LibXML; foreach(@files) { my $parser = XML::LibXML->new({recover => 2, suppress_errors => 1, suppress_warnings => 1, encoding => "utf8"}); my $tree = $parser->load_html(location => $_); ... }