in reply to recursive s///g core dumps

Works for 5.6.1 on linux-ppc. At least, it doesn't segfault. For those of us following along at home, what in the world is this:
$re = ${['(.+)\1']}[$depth]||'(.+)(\1)';
supposed to do? It looks like you're indexing into an array consisting of the single element '(.+)\1', which will be undef for any depth > 0, meaning $re will be '(.+)(\1)'. But I'm probably missing something.

/s
Update: Since my output doesn't even pretend to match boo_radley's, maybe I should go ahead and post it:

dofunc(AABBCC)
A
B
C
dofunc(A)
=B
dofunc(B)
=C
dofunc(C)
=D
=BCE
dofunc(AAAABBBBCCCC)
AA
BB
CC
dofunc(AA)
A
A
dofunc(A)
=B
=C
dofunc(BB)
B
B
dofunc(B)
=C
=D
dofunc(CC)
C
C
dofunc(C)
=D
=E
=CDF

Replies are listed 'Best First'.
Re: Re: recursive s///g core dumps
by I0 (Priest) on May 17, 2002 at 04:42 UTC
    ${['(.+)\1']}[$depth]||'(.+)(\1)'; just changes $re within the recursive call, which seems to be necessary to cause the core dump