|Pathologically Eclectic Rubbish Lister|
Re: 'Dynamic scoping' of capture variables ($1, $2, etc.) (localization of captures in recursions is buggy!)by LanX (Bishop)
|on Dec 16, 2012 at 21:03 UTC||Need Help??|
I understand your problem, for my understanding "dynamically scoped" should mean localized such that the sum at the end shouldn't be 4=1+1+1+1 but 1+7777+666+55.
but if you read the docs differently
you can see that the next match within the recursion sets $1 to another value.
At least that's ATM my understanding of the designers intention.
> a branch to a point within the same block
no, no tail-head optimization in Perl!
I will try to run some experiments tomorrow.
hmm, w/o recursion and with different strings it works like localized:
you're right there is a bug in how recursive functions are handled:
in contrast explicitly different functions:
the following shows that $1 is static per function, maybe they where implemented like closures.