Any way to "inject" an INIT block into a different module?

Rafael Garcia-Suarez rgarciasuarez at gmail.com
Fri May 30 14:30:22 BST 2008


2008/5/30 Adriano Ferreira <aferreira at shopzilla.com>:
> For the record, as far as I understand it, we don't inject INIT (or
> any other BEGIN, CHECK, END) blocks to a module, because it looks like
> Perl does not have such per-module control. Instead you need to time
> the injection to happen based on some of the compile statements Perl
> has: eval, do, require, etc. That's one of the things that is meant to
> be better documented as soon as these kind of rules become more clear
> to me. (For example, an INIT block injected at runtime may not run at
> all or maybe it runs at the next compile statement in some surprising
> way.)

Ah, but UNITCHECK has per-file control. And I see that the XS code in
Devel::Hook is pretty much the equivalent of the B based Perl code I
just posted in this thread.


More information about the london.pm mailing list