rootcho has asked for the wisdom of the Perl Monks concerning the following question:

hi
Sorry that i couldn't figure out better subject
I'm trying to apply Aspect "advices" inside the import()-sub
It doesnt seem to work ?
I think the reason for this is that the import() is executed at compile time and at this time the symbol-table is not populated with packages/methods I want to intercept. (the Aspect module looks-up the symbol table to hook-up/install its pre and post handlers), but if the package::methods are not yet "imported" it is normal to not be able to hook them
Do you have idea for a solution to this problem ?
Is there a way to install a subroutine to be called after all the modules has been use'd i.e. symbol table is populated
thank you very much?
  • Comment on import() and symbol-table population!? (compile vs. runtime)

Replies are listed 'Best First'.
Re: import() and symbol-table population!? (compile vs. runtime)
by dirving (Friar) on Feb 06, 2007 at 19:04 UTC

    One possibility could be to use a CHECK or INIT block, which run after the initial compile time but before the execution of the program starts. See the "BEGIN, CHECK, INIT, and END" section of perlmod for more on exactly when these blocks are run.

    -- David Irving

      A few days (might be weeks, I'm not that good with large quantities of time) ago I uploaded Filter-EOF to CPAN to ease the execution of code post-compile time. In it's 0.02 version it also allows to inject code at the end of the file.

      I would try the INIT approach you mentioned first, though, to see if it's convenient enough.


      Ordinary morality is for ordinary people. -- Aleister Crowley