http://www.perlmonks.org?node_id=1061988


in reply to Re: weaken CODEREF
in thread weaken CODEREF

Correctamundo! Usually this optimization doesn't cause any issues, but if you're finding that it does, the solution is to force Perl to close over a variable. A short string or small integer is ideal, as they'll waste very little memory.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name