use warnings; use strict; use Encode; use XML::Twig; use HTML::Table; undef $/; my $html = ; my $twig = XML::Twig->new( input_filter => sub { my $txt = shift; return decode('Windows-1252', $txt); }, output_text_filter => 'safe_hex', pretty_print => 'indented', twig_print_outside_roots => 1, twig_roots => { 'h1' => sub { ### If 1: ### - "Wide character in print..." ### - TM is *not* converted to ™ by output_text_filter ### If 0: ### - No character complaints ### - TM *is* converted if (1) { my $new_elt = XML::Twig::Elt->new('div'); my $table = HTML::Table->new([[1,2]]); $new_elt->set_inner_html($table->getTable()); $new_elt->paste(before => $_); } $_->flush(); } }, ); $twig->parse_html($html); __DATA__

Such and Such™