Re: [perl #75792] Unexpected nested closure circular reference (possibly a Scalar::Util::weaken issue?)
[email protected] (Bo Lindbergh)
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <[email protected]> |
Not related to weaken.
$self is captured because the intermediate anonymous sub mentions it.
Try this instead:
sub closure_factory {
my $self = {};
sub {
my $weakself = $_[0];
weaken $weakself;
$weakself->{coderef} = sub { die $weakself if $weakself };
}->($self);
$self;
}
/Bo Lindbergh