in reply to Re: coderef to an object method
in thread coderef to an object method
data => sub { $self->gotodata(@_) },There is a gotcha in this, in that you have just made your anonymous sub into a closure. Note that $self is in the pad space of the surrounding code, and its value is the one object that is around when the line is executed.
I have seen memory leaks, where the coderef gets stored into a member of $self's hash (or some structure deeper under $self), leading to a subtle circular reference.
--
I'm Not Just Another Perl Hacker
|
|---|