diff options
Diffstat (limited to 'ext/Opcode/Safe.pm')
-rw-r--r-- | ext/Opcode/Safe.pm | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/ext/Opcode/Safe.pm b/ext/Opcode/Safe.pm index c9d741647e..940a972fd1 100644 --- a/ext/Opcode/Safe.pm +++ b/ext/Opcode/Safe.pm @@ -53,11 +53,11 @@ sub new { sub DESTROY { my $obj = shift; - $obj->erase if $obj->{Erase}; + $obj->erase('DESTROY') if $obj->{Erase}; } sub erase { - my $obj= shift; + my ($obj, $action) = @_; my $pkg = $obj->root(); my ($stem, $leaf); @@ -73,18 +73,22 @@ sub erase { #warn " stem_symtab hash ".scalar(%$stem_symtab)."\n"; # ", join(', ', %$stem_symtab),"\n"; - delete $stem_symtab->{$leaf}; +# delete $stem_symtab->{$leaf}; -# my $leaf_glob = $stem_symtab->{$leaf}; -# my $leaf_symtab = *{$leaf_glob}{HASH}; + my $leaf_glob = $stem_symtab->{$leaf}; + my $leaf_symtab = *{$leaf_glob}{HASH}; # warn " leaf_symtab ", join(', ', %$leaf_symtab),"\n"; -# %$leaf_symtab = (); + %$leaf_symtab = (); #delete $leaf_symtab->{'__ANON__'}; #delete $leaf_symtab->{'foo'}; #delete $leaf_symtab->{'main::'}; # my $foo = undef ${"$stem\::"}{"$leaf\::"}; - $obj->share_from('main', $default_share); + if ($action and $action eq 'DESTROY') { + delete $stem_symtab->{$leaf}; + } else { + $obj->share_from('main', $default_share); + } 1; } |