use strict; use XML::Twig; my $string = '

here the paragraph comes

here the paragraph comes

here the paragraph comes

here the paragraph comes

here the paragraph comes here the paragraph comes here the paragraph comes here the paragraph comes here the paragraph comes here the paragraph comes here the paragraph comes here the paragraph comes here the paragraph comes here the paragraph comes here the paragraph comes here the paragraph comes
'; my $twig = new XML::Twig( twig_handlers => { p => sub { $_->add_id() } #generate id a => sub { $_->add_id() }, #generate id }, pretty_print => 'indented' #print format ); #my $twig1 = new XML::Twig( # # twig_handlers => { # a => sub { $_->add_id() } #generate id # }, # pretty_print => 'indented' #print format #); $twig->set_id_seed( "fig" ); $twig->parse($string); $string = $twig->sprint; #$twig1->set_id_seed( "sec" ); #$twig1->parse($string); #$string = $twig1->sprint; print $string;