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

Abigail abigail at
Fri May 30 16:46:00 BST 2008

On Fri, May 30, 2008 at 04:17:45PM +0100, Andy Wardley wrote:
> Abigail wrote:
> >Well, if it's acceptable to do the "use Control" from the module
> >(as you were doing it initially), wouldn't moving the "use Control" to
> >end of the package solve the problem? By the time Control -> import ()
> >gets called, all the subs of are defined.
> Yes, it would.  Although it might be a bit backwards have a "use" right at
> the end of the file.  Furthermore, the real equivalent of my Control module
> is also defining some constant subroutines and package vars that really do
> need to be done up front so they can be used in the code body.  But I could
> just as easily call another method at the end.
>     use Control qw( volume sustain );
>     # my code
>     blah blah $CONTROLS;     # $CONTROL is exported by Control, for e.g.
>     __PACKAGE__->generate_controls;
> Or I could put the explicit generate_controls() call in an INIT block at the
> top.  But then we're back to manually doing what I'm trying to automate from
> the Control module.

You could add the '__PACKAGE__->generate_controls;' automatically using
a *cough*source*cough*filter*cough*.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url :

More information about the mailing list