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

Abigail abigail at
Fri May 30 19:27:51 BST 2008

On Fri, May 30, 2008 at 01:26:36PM +0100, Andy Wardley wrote:
> I'm messing with INIT blocks, trying to get some methods auto-generated at
> the right time.
> Here's an example.  Let's say I have an amplifier.  Naturally, it goes up
> to eleven.
>     package Amp;
>     use Control qw( volume sustain );
>     sub volume {
>         print "This amp goes up to eleven\n"
>     }

Another thing you can do is to create the subroutines in
unconditionally (at import time), and write like this:

    package Amp;

    use Control qw (volume sustain);
    no warnings 'redefine';

    sub volume {


-------------- 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