in reply to Re^2: No DESTROY object.
in thread No DESTROY object.
Errr ... no, it is not:
Because:perl -we 'bless( \sub {}, "Foo" )->();' Not a CODE reference at -e line 1.
perl -we 'print bless( \sub {}, "Foo" ) . "\n";' Foo=REF(0x82998c4)
Update: To answer your question: What seems to be happening is that perl inlines the subroutine. See:
use strict; use warnings; package Foo; sub new { my $class = shift; return bless( sub { print "Hello\n" }, $class ); } sub DESTROY { print "DESTROYing $_[0]\n"; return; } package main; my $object = Foo->new; print "Created $object\n"; undef $object; print "Ha! Ha! Still there!\n"; { no strict 'refs'; my $symbol_table = \%{'Foo::'}; delete $symbol_table->{'new'}; } print "Done.\n";
# Created Foo=CODE(0x82b682c) # Ha! Ha! Still there! # DESTROYing Foo=CODE(0x82b682c) # Done.
In Section
Seekers of Perl Wisdom