in reply to Re: INIT blocks and runtime code loading
in thread INIT blocks and runtime code loading
BEGIN import INITHowever, adding an import subroutine to the above code produces:
BEGIN INIT importOne possible workaround for this would be to move any INIT code to the end of the import subroutine. Yet even this is not a 100% solution as:
causes the import subroutine - and hence the moved INIT code - not be be executed.use testpkg ();
For the module I'm writing, I have a BEGIN block, an import subroutine, and an INIT block. The INIT block consists of just one function call. Therefore, I warn the user that if they want delayed evaluation of my module, they must do so as follow:
eval { require MyModule; import MyModule qw/.../; MyModule::MyInit(); }
|
|---|