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

I'm confused, for me it looks like you are just assigning the old values back.²

And if IIRC nested packages are hold in the %main:: stash.¹

So either your example is wrong or I'm lacking enough understanding of whats going on.

Cheers Rolf

1) wrong, I misunderstood perlmod

{ package ding::dong; $x=1 } $\="\n"; print $ding::dong::x; # prints 1 print $main::{"ding::"}; # *main::ding:: print $main::{"ding::"}->{"dong::"}; # *ding::dong:: print $main::{"ding::"}->{"dong::"}->{x}; # *ding::dong::x

2) AHH now I got it... you're just keeping the sub packages (here "dong::" of "ding::") and cleaning anything else.