use warnings; use strict; use XML::Twig; my $str = < goo EOF my $t = XML::Twig->new(comments => 'keep'); $t->parse($str); $t->print(); print "\n"; __END__ goo