A state machine that does it all in one pass has been my holy grail for like 4 years now. Btw.. when I say I've been working on it for 4 years that's not like 4 years of sustained effort or anything, it's a good coding session every now and then interspersed with a lot of other things!

Surely this  $aXML =~ s@;([^:;]+?):@\[$1\(@gs; is the only backtracker there, and also it comes prior to the "save this to disc then process" marker so it only gets run once when the page is still in it's raw aXML state, not every time the page is requested.

That leaves this while ($aXML =~ m@\[([^\[\]]*?)\]@gs) { ... }

Which makes as many passes as it needs to decode the structure, in what I visualise as a sort of 3d way with the innermost tags being the highest peaks getting mown down one tag height at a time, until the document is flat.

Hrm, maybe I could save the $level data into an array to determine character positions for processing... that would help!


In reply to Re^2: Fast enough yet? by Logicus
in thread Fast enough yet? by Logicus

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.