in reply to recursive s///g core dumps

I think perl's clobbering or removing backreferences somewhere, and you're trying to access \1 after perl's done something else with it.
If $1 is assigned to a temp var within dofunc, the code no longer dumps core. Below is my test, and output...

#!/usr/bin/perl -w use strict; my $weeping; print doFunc( "AABBCC",0 ); print doFunc( "AAAABBBBCCCC",0 ); sub doFunc { my( $theParam,$depth) = @_; print STDERR "\ndofunc($theParam)\n"; my $re; $re = ${['(.+)$weeping']}[$depth]||'(.+)($weeping)'; print STDERR join"\n", $theParam =~ /$re/g,undef; $theParam =~ s/$re/&doFunc($weeping,$depth+1)/ge; $weeping=$1; ++$theParam; print STDERR "=$theParam\n"; return $theParam; }


and this gives us

dofunc(AABBCC) =AABBCD AABBCD dofunc(AAAABBBBCCCC) =AAAABBBBCCCD AAAABBBBCCCD


Now, if you'll excuse me, I need to go wash my hands compulsively :-)
update so what output do you expect, out of curiosity?