On Sun, Jan 29, 2012 at 10:35 PM, Father Chrysostomos via RT <perlbug-followup@perl.org> wrote: > $foo = $foo_life_raft = sub { &$bar }; > weaken($foo); > I usually like to call the variable $life_raft or similar in my own > code, because it keeps the referent ‘afloat’ till the end of the > enclosing scope. > That example will work if $foo is the closure that will be returned or > assigned to something. If $bar is to be returned, then $bar has to be > weakened (with a $bar_life_raft to keep it alive till the end of sub leak). Thanks, nice approach.Thread Previous | Thread Next