The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
How do I force the "import" to be the first executed statement? You can't (at least not with the desired arguments), because cacher->import(...) is being called after the module has been required — at which point any code of the module outside of subroutines will already have been run. That's how use works... Update: it's maybe worth mentioning that import is not being called at all if you say use cacher ();. If that's an issue in your case, you might want to setup %cachehash with a default directory at the time the module is being required. Then, in case import is being called, just re-initialize %cachehash with the directory specified as the argument to use. Kind of like this:
(From a performance point of view, doing things twice is of course suboptimal...) P.S.: if you use Exporter in the same package, you probably want to explicitly call its import routine with the appropriate arguments (first arg = your package name), because normally the import method will be inherited from Exporter. In other words, Exporter's import will no longer be called (automatically) when you implement import yourself... In reply to Re^3: Skeleton For Import to Package?
by almut
|
|