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

Matt Lawrence matt.lawrence at virgin.net
Fri May 30 14:56:20 BST 2008


Marcel Grünauer wrote:
>
> On May 30, 2008, at 2:26 PM, Andy Wardley wrote:
>
>>    use Control qw( sex drugs );
>>
>>    # later...
>>    eval "use Amp";
>>    Amp->volume;
>>    Amp->sustain;
>
> use() = require() + import()
>
> eval() doesn't have the import() part, so you need to call it manually.
eval "use ..." does do import(), it just does it at run time. The 
problem is that the INIT block that reads @HOOKS doesn't get called 
after a run-time import has populated it.

Matt



More information about the london.pm mailing list