namespace::local - confine imports to current scope
namespace::clean (along with its cousins namespace::autoclean and namespace::sweep) allows to "forget" imported functions, only making them available for the current package. This is neat.
After looking at the inside of namespace::clean, I thought I could do an inside-out version that would erase imports that come after and not before it. A prototype turned out surprisingly easy to implement.
The usage is as follows:
package My::Package;
sub normal_funtion {
# no traces of quux exist
};
sub function_with_import {
use namespace::local;
use Foo::Bar qw(quux); # some crazy prototyped DSL
# quux available here
};
sub another_normal {
# no traces of quux exist
};
I have at least one use case where importing a lot of functions into a single scope makes sense.
Do you have more?
Leave a comment