in reply to Timing a Module Load

Is there a way to force the module to "unload".

I would presume that a use statement which falls out of scope would automatically "unload" the module:

#!/usr/bin/perl -w use strict; { use Date::Manip; } print Date::Manip::UnixDate(localtime);

However the above code parses and runs without error, indicating that use isn't limited to a particular scope. Can someone explain why modules aren't (or at least do not appear to be) limited by scope?

Replies are listed 'Best First'.
Re^2: Timing a Module Load
by Tanktalus (Canon) on Apr 30, 2005 at 03:57 UTC

    When you "use" a pragma, it gets scoped. But using a module is not scoped. Either way, this is all done during compile time, not run time (even though it may affect the runtime, such as "no warnings qw(uninitialized)").

    So, you use Data::Manip. This is done during compilation. Then, at run time, those braces really have nothing in them (the use being completed at run time only).