in reply to What is the correct way to clear package?

For future compatibility, deleting should be safer than setting.

my $pkg = \%{ $pkg_name . '::' }; delete $pkg->{$_} for grep !/::\z/, keys %$pkg;

Update: Or even

my $pkg = \%{ $pkg_name . '::' }; delete @{$pkg}{ grep !/::\z/, keys %$pkg };

Replies are listed 'Best First'.
Re^2: What is the correct way to clear package?
by vokbuz (Novice) on May 06, 2011 at 07:55 UTC
    I've tried delete but for some reason it doesn't work fine with "use base" after reloading.