in reply to better way to cleanup a package?
Many caveats. It's not good for unusing a module. See the above comments about @INC. Also it won't remove exported symbols. So if you export function Pack::Foo::foo(), the symbol table that it was exported to will still have foo() available after it's been erased.sub ERASE_PACKAGE { # Call with "Package::Name" my $packname = shift; $packname .= '::' unless $packname =~ /::$/; no strict "refs"; warn $packname; my $package = *{$packname}{HASH}; return unless defined $package; undef *{$packname . $_} foreach (keys %$package); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: better way to cleanup a package?
by gmpassos (Priest) on Dec 03, 2002 at 19:27 UTC | |
by shotgunefx (Parson) on Dec 04, 2002 at 01:50 UTC |