in reply to Recursive insertion of tags

You could do it in a simple subtitution:

$file =<<EOF; <ins cnt="4"> blah <ins cnt="2"> EOF + $file =~ s/<ins cnt="(\d+)">/"<TAG>" x $1/egs; + print $file;
Note the /e modifier to the substitution that permits the evaluation of code in the RHS.

/J\