http://www.perlmonks.org?node_id=1042907

shawnhcorey has asked for the wisdom of the Perl Monks concerning the following question:

What is the best way to get Perl to use UTF-8 for everything, except for when I explicitly state otherwise. I was using use encoding qw( UTF-8 ); but in Perl 5.18 it's deprecated. I using this as a stop-gap:

use open qw( :encoding(utf8) ); binmode STDIN, qw{ :encoding(UTF-8) }; binmode STDOUT, qw{ :encoding(UTF-8) }; binmode STDERR, qw{ :encoding(UTF-8) };

Surely, there must be a more elegant way.

And a related question: In the HTML::TreeBuilder documentation, it says, "When you pass a filename to "parse_file", HTML::Parser opens it in binary mode, which means it's interpreted as Latin-1 (ISO-8859-1). If the file is in another encoding, like UTF-8 or UTF-16, this will not do the right thing."

What would be a good replacement for HTML::TreeBuilder, keeping in mind that not all HTML pages are XML compliant?