in reply to Unloading a module completely

Unload a module, actually unload a package, is hard. You need to scan all the package to undef all the data types (SCALAR, ARRAY, HASH, GLOB) and close the IO too. Also you need to overload the subs with a DUMMY sub. But when you "undef" a package you can't use that package name again, or you will have a core dump easy in the future codes!

For XS code you can use some unload_file() method (I don't remember now the method name) of Dynaloader, but this only work for Linux and isn't stable. Soo, I have skiped that!

But the problem is that when you load a code, or module, it generally set new symbols in the other packages (in other symbols tables). Soo, I think that the best way is to create a Safe compartment and load your code there.

But to make your code load modules inside a Safe compartment is hard, since you need to implement by hand the output, %INC and @INC handlers. Soo, I have created Safe::World, that implements all the World and already have the CLEAN() resource that you are looking. It also has other cool things, but I will let them to be read in the POD.

Get it at: http://search.cpan.org/~gmpassos/Safe-World-0.03/

I will been releasing the 0.04 version in some days, soo be updated...

Graciliano M. P.
"Creativity is the expression of the liberty".