You're right, I would have expected that too. Looking more closely, it turns out that it doesn't get constant-folded at all - I guess the repeat operator isn't included for that optimisation.
(I checked by modifying the code to call the coderef twice, and then examined the trace produced by perl -Dt.)
So it would appear that it is just the anonymous pad variable for the subexpression target that is grabbing the memory.
Hugo
|