<?xml version="1.0" encoding="windows-1252"?>
<node id="154569" title="recursive /eg fails" created="2002-03-26 21:49:45" updated="2005-07-21 01:31:11">
<type id="115">
perlquestion</type>
<author id="44950">
I0</author>
<data>
<field name="doctext">
#&lt;code&gt;
# I've striped down the core dump example,
# It no longer core dumps under v5.6.1 but it still returns the wrong answer
# Can anyone explain why /C(2)/ is not getting substituted?
use strict;

print doFunc( "MAIN", "B(1)+C(2)" );
sub doFunc{
   my $theFunc = shift;
   local $_ = shift;
   my $re;
   $re = ${{
"B(1)+C(2)" =&gt; '1|2',
}}{$_}||quotemeta;

   print "$theFunc: '$_'=~/$re/\n";
   print join"\n",/(\w+)\(($re)\)/g,"\n";

   $_ =~ s/(\w+)\(($re)\)/&amp;doFunc($1,$2)/eg; # /ego works /eg fails
    return "func $theFunc returns &lt;$_&gt;";
}
#should return
#func MAIN returns &lt;func B returns &lt;1&gt;+func C returns &lt;2&gt;&gt;
#&lt;/code&gt;
</field>
</data>
</node>
