in reply to Multilevel tag closing

This works for your example input, but is not general. You should be able to base the general solution on it, though.
#!/usr/bin/perl use warnings; use strict; my $level = 0; while (<>) { if (m%<P_list-bull\(1\)>(.*?)</P_list-bull\(1\)%) { my $text = $1; if ($level == 0) { print qq{<list list-type="bullet">\n}; } elsif ($level == 1) { print "</p></list-item>\n"; } elsif ($level == 2) { print "</list></p></list-item>\n"; } print "<list-item><p>$text"; $level = 1; } elsif (m%<P_list-simple\(2\)>(.*?)</P_list-simple\(2\)>%) { my $text = $1; if ($level == 1) { print qq{\n<list list-type="simple">\n}; } print qq{<list-item><p>$text</p></list-item>\n}; $level = 2; } } if ($level == 1) { print "</p></list-item>\n</list>\n"; }
BTW, the one who created the original format probably never thought about the possibility anyone would like to use it.