in reply to weaken CODEREF

I can confirm this behaviour on perl 5.18.1 with Scalar::Util 1.35. Looks like a bug to me.

Note that the correct behaviour can be obtained using the experimental “lexical subroutines” feature, introduced in perl 5.18.0 (see perlsub):

#! perl use strict; use warnings; use feature 'lexical_subs'; use Scalar::Util 'weaken'; my $ref; { my sub frobnicate { print 42; } my $local_ref = \&frobnicate; # $ref = $local_ref; weaken($ref = $local_ref); } $ref->();

Output:

12:49 >perl 775_SoPW.pl The lexical_subs feature is experimental at 775_SoPW.pl line 10. Can't use an undefined value as a subroutine reference at 775_SoPW.pl +line 20. 12:49 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,