use strict;
use XML::Twig;
my $string = '
here the paragraph comes
here the paragraph comes
here the paragraph comes
';
my $twig = new XML::Twig(
twig_handlers => {
p => sub { $_->add_id() }, #insert element id
},
pretty_print => 'indented' #print format
);
$twig->set_id_seed( '' );
$twig->parse($string);
$string = $twig->sprint;
print $string;
output:
-------
here the paragraph comes
here the paragraph comes
here the paragraph comes