user391986
user391986

Reputation: 30906

perl html treebuilder not returning string

When I use

my ($key, $seperator, $value) = map $_->as_text, $row->content_list;

I get horribly nasty output back.

$VAR1 = 'Numberáofásourceálines';
$VAR2 = 'á23182';
$VAR3 = 'Htmlágeneratedáat';
$VAR4 = 'áMonáJuná13á11:06:46á2011';
$VAR5 = 'Coverageáview';
$VAR6 = 'áAsáinstrumented';
$VAR7 = 'Symboláfile(s)';

If I try as_html it's more decent but needs to get parsed...

$VAR1 = '<td class="red">TER</td>';
$VAR2 = '<td class="red">&nbsp;<strong>43%</strong>&nbsp;(function)</td>';
$VAR3 = '<td class="black">Threshold&nbsp;percent</td>';
$VAR4 = '<td class="black">&nbsp;<strong>100</strong>&nbsp;%</td>';
$VAR5 = '<td class="black">Number&nbsp;of&nbsp;source&nbsp;lines</td>';
$VAR6 = '<td class="black">&nbsp;23182</td>';

EDIT Unknown PerlIO layer 'encoding(cpActive' at myscript.pl line 27 Unknown PerlIO layer 'code' at myscript.pl line 27 Unknown PerlIO layer 'page:' at myscript.pl line 27 Unknown PerlIO layer '437)' at myscript.pl line 27 Cannot find encoding "cpActive :code :page: :437" at C:/Perl/lib/open.pm line 120. Cannot find encoding "cpActive :code :page: :437" at C:/Perl/lib/open.pm line 128.

Upvotes: 0

Views: 251

Answers (1)

ikegami
ikegami

Reputation: 385917

Your nasty output if the result of you not properly encoding your text on output. If you're printing to STDOUT, the following should do the trick:

use open ':std', ':locale';

Or on Windows:

sub acp { my ($cp) = `chcp` =~ /([0-9]+)/; $cp }
use open ':std', ':encoding(cp'.acp().')';

Upvotes: 2

Related Questions