Module:
package MyModule; use IO::Socket::INET; 1;
Main script:
use MyModule; my $socket = IO::Socket::INET->new();
This works fine, but if I now replace/reimplement MyModule so that it has the same API (intended to be a drop-in replacement) but doesn't need (and thus use) IO::Socket::INET internally, the main script will break because it can't find IO::Socket::INET anymore.
To avoid something like this from happening, I was wondering if it's possible to stop use statements within modules from effectively propagating into their caller. This would mean that the example I posted would break and force me to use IO::Socket::INET right away, preventing issues later on.
(This bleeding actually seems to go both ways. I just had a module break on me because I removed a use of another module from my main script. And in this it was actually one of the modules used by the module I removed that actually used the module needed by the second module.)
In reply to Preventing used modules from leaking to main script by Crackers2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |