Closures that enclose themself represent a reference cycle which is a.k.a. a memory leak. If you need a self referencing sub you should localize a glob to do it. Ie:
local *recursive=sub { ... recursive(...); };
This keeps the self references "soft" and means that when it goes out of scope the sub will be freed. Doing it via lexicals is not correct
my $recursive;
$recursive=sub{ ... $recursive->(...); };
as it will leak. (Meaning the sub referenced by $recursive will not be freed until global destruction.)
---
$world=~s/war/peace/g
|