use feature qw{ say };
use List::Util qw{ uniq };
my @headers = sort +uniq(map $_->value,
$dom->findnodes('/tmx/body/tu/prop/@type'));
for my $tu ($dom->findnodes('/tmx/body/tu')) {
my %props;
for my $prop ($tu->findnodes('prop')) {
$props{ $prop->findvalue('@type') } = $prop->textContent;
}
print join("\t", map $_ // "", @props{@headers}), "\t";
for my $child ($tu->findnodes('tuv')) {
( my $text = $child->textContent ) =~ s,\n,
,g;
print $text, "\t";
}
print "\n";
}
__END__
aligned client corrected domain project subject
no no Hello
world! Bonjour
monde
no no yes Hello
world! Bonjour
monde