Here the ids are sequence for both the elements. I want to start the new id for 'a' element again from sec1. output i got: -------------

here the paragraph comes

here the paragraph comes

here the paragraph comes

here the paragraph comes

here the paragraph comes #note here id is not restarting 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
#### Required Output: ----------------

here the paragraph comes

here the paragraph comes

here the paragraph comes

here the paragraph comes

here the paragraph comes #note here it restarts again 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
##
## 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;