<?xml version="1.0" encoding="windows-1252"?>
<node id="318386" title="Re: Being Forced to Fork with Nested Regular Expressions" created="2004-01-02 13:12:33" updated="2005-03-26 18:50:16">
<type id="11">
note</type>
<author id="249603">
halley</author>
<data>
<field name="doctext">
I also wanted to abuse the regex system with twelve-level-deep &lt;code&gt;s///e&lt;/code&gt; recursion to implement my [id://253363], but instead found that perl would crash horribly if it tried to recurse there.

&lt;code&gt;
for $pattern (@patterns)
{
    while ($data =~ m/(?=$pattern)/g)
    {
        do_recurse($data, pos($data), $pattern);
        # $data is the source
        # pos($data) is the found place in the souce
        ++pos($data);
    }
}
&lt;/code&gt;

The alternative method uses &lt;code&gt;pos()&lt;/code&gt; as an lvalue and &lt;code&gt;m/(?=)/g&lt;/code&gt; as in the loop above, to allow me to iterate through matches yet not recurse via any regex code-evaluating trick.  I do recurse, but not by getting the regex to do the call.

&lt;div class="pmsig"&gt;&lt;div class="pmsig-249603"&gt;
&lt;p&gt;--&lt;br&gt;&lt;tt&gt;&amp;#91; e d @ h a l l e y . c c &amp;#93;&lt;/tt&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
318350</field>
<field name="parent_node">
318350</field>
</data>
</node>
