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 };
In reply to Re: What is the correct way to clear package?
by ikegami
in thread What is the correct way to clear package?
by vokbuz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |