Since the monastary was so helpful with my last question, here's a followup/further question. I was trying to implement the
(??{CODE})
sequence for a matching regexp to match a string with balanced braces using this recursion regexp:
$np = qr{ \{ (?: (?> [^{}]+ ) | (??{ $np }) )* \} }x;
It turned out the problem I had was that I was using an old version of perl that didn't support the delayed interpolation sequence. So no problem, I upgraded and all is fine and dandy etc. But here's my question: Lets say that the sequence didn't exist, or that I'm using perl circa Billy Idol or something. I know that without this newer form of perl recursion a standard regex wouldn't be able to make this type of nested brace match(or so I've been told by coders more knowledgable than I). So my thinking went like this: When I finally decided I needed some monk advice for my previous problem, I had already invested a lot of time and energy into what I had hoped would be a handy and useful program. How could I have at least come close to the function of the newer sequence without using it? By this I mean, if I was unable to use the delayed interpolation sequence and had to replace the regex with some "old fashioned" code, what would my options be? I was very worried about this problem until my salvation yesterday, now its only a "what if" question for people who are in the know. Don't worry, everything is working fine :-) I was just wondering what, say, the author of the recdescent module did to achieve similar effect back in the dark ages.

In reply to Balancing braces without (??{}) by tshabet

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.