This may have some idea where to start, or then again it might not :)

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11163097 use warnings; use List::Util qw( reduce ); local $/ = ''; # read paragraphs while( <DATA> ) { my @terms = /<term>(.*?)</g; print "Input: @terms\n"; my @fails; reduce { if( $a =~ /^\d/ ) { $a + 1 == $b or push @fails, "fail at $a -> $b\n"; } else { my $left = $a =~ tr/a-z/b-za/r =~ s/^a/aa/r; $left eq $b or push @fails, "fail at $a -> $b\n"; } $b } @terms; print @fails; print "\n"; } __DATA__ <list> <item> <term>1.</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>3.</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>4.</term> <para>jhjhjh hjkjkjkj</para> </item> </list> <list> <item> <term>a)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>b)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>d)</term> <para>jhjhjh hjkjkjkj</para> </item> </list> <list> <item> <term>aa)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>cc)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>dd)</term> <para>jhjhjh hjkjkjkj</para> </item> </list> <list> <item> <term>xx)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>yy)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>zz)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>aaa)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>bbb)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>yyy)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>zzz)</term> <para>jhjhjh hjkjkjkj</para> </item> <item> <term>aaa)</term> <para>jhjhjh hjkjkjkj</para> </item> </list>

Outputs:

Input: 1. 3. 4. fail at 1. -> 3. Input: a) b) d) fail at b) -> d) Input: aa) cc) dd) fail at aa) -> cc) Input: xx) yy) zz) aaa) bbb) yyy) zzz) aaa) fail at bbb) -> yyy) fail at zzz) -> aaa)

In reply to Re: Check numbering of list items by tybalt89
in thread Check numbering of list items by LexPl

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.