use warnings; use strict; use XML::Twig; my $str = <

Some text

EOF my $t = XML::Twig->new( twig_handlers => {li => \&li}, pretty_print => 'indented', ); $t->parse($str); $t->print(); sub li { my ($t, $elt) = @_; for my $p ($elt->children('p')) { for my $c ($p->cut_children()) { $c->paste($elt); } $p->delete(); } } __END__
  • text Some