Note that the above leaks if the anon sub accesses $bar. That would be the case if the anon sub is recursive, for example. I find the following simpler, and it doesn't leak.
sub foo { ... local *bar = sub { ... }; bar(...); }
In reply to Re^2: a sub within a sub -- revisiting
by ikegami
in thread a sub within a sub -- revisiting
by punkish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |