http://www.perlmonks.org?node_id=908503


in reply to Group XML

I do not understand exactly what should be wrapped into groups (the beginning of the output is missing, anyway). To insert CDATA and change rid attributes, you can use XML::XSH2 in this way:
open 908451.xml ; for $t in //title/text() insert cdata $t replace $t ; for //article-ref/@rid insert text xsh:subst(., '.*-2_' , '') replace . ;
The rest would be also possible if you can explain the algorithm.