Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Check numbering of list items

by tybalt89 (Monsignor)
on Dec 09, 2024 at 16:35 UTC ( [id://11163106]=note: print w/replies, xml ) Need Help??


in reply to Check numbering of list items

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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11163106]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2025-11-16 18:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (72 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.