in reply to Code Reuse
And import is executed in the context of the calling package.
Thus you can call other imports inside a generic import to export into the calling namespace.
For instance:
package generic; use strict; # * ... sub import { strict->import(); ... }
You might wanna have a look into the source of Modern::Perl for more examples.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
*) Had to change require strict; to use strict; to make it work. (not sure why)
It's a timing issue, the require has to happen in a BEGIN or inside the import (use does it automatically), this works
package generic; sub import { require strict; strict->import(); ... } 1;
|
---|