in reply to undef Package;

If you're using 5.004 or later (i think), then you just need to use Symbol:

use Symbol qw(delete_package); delete_package('Foo::Bar');

But i wonder whether you wouldn't be better off localising the package somehow in the first place? Either within a process or by some clever closure or other. And now i really am out of my depth :(

Replies are listed 'Best First'.
Re: Re: undef Package;
by Juerd (Abbot) on Apr 03, 2002 at 16:17 UTC

    If you're using 5.004 or later (i think), then you just need to use Symbol

    ++! That's what I was looking for. Fortunately, it's in the core distribution.

    It seems I was very close:

    # from Symbol.pm # free all the symbols in the package my $leaf_symtab = *{$stem_symtab->{$leaf}}{HASH}; foreach my $name (keys %$leaf_symtab) { undef *{$pkg . $name}; }
    But Symbol does a bit more than I did:
    # delete the symbol table %$leaf_symtab = (); delete $stem_symtab->{$leaf};
    Which I didn't do, because it seemed that it didn't work at all. However, it probably didn't work in an rmdir way: there were still symbols in the table. (rmdir doesn't delete non-empty directories)

    U28geW91IGNhbiBhbGwgcm90MTMgY
    W5kIHBhY2soKS4gQnV0IGRvIHlvdS
    ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
    geW91IHNlZSBpdD8gIC0tIEp1ZXJk