go ahead... be a heretic | |
PerlMonks |
Re^4: Defining a sub within a sub: OK?by ikegami (Patriarch) |
on Oct 15, 2009 at 12:49 UTC ( [id://801345]=note: print w/replies, xml ) | Need Help?? |
It leaks memory.
Compare the refcount of $x (which will get freed) to $_recur's (which won't). The problem is that the sub referenced by $_recur captures $_recur, and thus you have a memory loop. If you wanted a lexical, you would need to use
This is a lot messier.
In Section
Seekers of Perl Wisdom
|
|