Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: What delete from symbol table really means? Symbol::delete_package

by Anonymous Monk
on Feb 16, 2015 at 19:28 UTC ( [id://1116913]=note: print w/replies, xml ) Need Help??


in reply to Re^2: What delete from symbol table really means? (Deleting typeglob of a specified package)
in thread What delete from symbol table really means? (Deleting typeglob of a specified package)

see Symbol Symbol::delete_package
# # of Safe.pm lineage # sub delete_package ($) { my $pkg = shift; # expand to full symbol table name if needed unless ($pkg =~ /^main::.*::$/) { $pkg = "main$pkg" if $pkg =~ /^::/; $pkg = "main::$pkg" unless $pkg =~ /^main::/; $pkg .= '::' unless $pkg =~ /::$/; } my($stem, $leaf) = $pkg =~ m/(.*::)(\w+::)$/; my $stem_symtab = *{$stem}{HASH}; return unless defined $stem_symtab and exists $stem_symtab->{$leaf +}; # free all the symbols in the package my $leaf_symtab = *{$stem_symtab->{$leaf}}{HASH}; foreach my $name (keys %$leaf_symtab) { undef *{$pkg . $name}; } # delete the symbol table %$leaf_symtab = (); delete $stem_symtab->{$leaf}; }
  • Comment on Re^3: What delete from symbol table really means? Symbol::delete_package
  • Download Code

Replies are listed 'Best First'.
Re^4: What delete from symbol table really means? Symbol::delete_package
by LanX (Saint) on Feb 16, 2015 at 19:42 UTC
    See what? I have no idea what the pasted code is supposed to prove.

    Please take advantage of preview before posting code.

    BTW: see also Re^2: dumping lexical filehandles (not in STASH), showing that the slots PACKAGE and NAME are sometimes wrongly set in Perl (lexicals have no package)

    Cheers Rolf

    PS: Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1116913]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found