Subject: | There's still a reference held to deleted subs |
Subject: | destroyal.pl |
use v5.16;
use strict;
use warnings;
use Sub::Delete 'delete_sub';
use Devel::Refcount 'refcount';
package Foo {
sub bar { 42 }
}
my $coderef = \&Foo::bar;
# Refcount should be 2:
#
# - reference in $coderef
# - reference in symbol table for Foo
#
print "THIS SHOULD BE 2: ", refcount( $coderef ), "\n";
delete_sub 'Foo::bar';
# Refcount should be 1:
#
# - reference in $coderef
#
print "THIS SHOULD BE 1: ", refcount( $coderef ), "\n";