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.

In reply to Re: Multilevel tag closing by choroba
in thread Multilevel tag closing by maha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.