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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.