The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Call::Immediate - Export subs that are called as soon as they are seen at compile time

SYNOPSIS

    package MyModule;

    sub class {
        # muck around with symbol tables and stuff
    }
    
    # still have to export manually
    use Exporter;
    use base 'Exporter';
    our @EXPORT = qw<class>;

    # Use this module to have them executed immediately
    # when they are seen.
    # ALWAYS use this module at the END of your module definition!
    use Call::Immediate qw<class>;

DESCRIPTION

This module installs a very simple source filter that causes the subs you specify to be called as soon as they are seen, like macros (but ones that don't substitute any text). This allows you to create slightly more natural constructs like:

    class Foo => sub { 
        ...
    };

As soon as this is seen in the user's file, your class sub will be executed, so that you can mess with the symbol table and affect compilation of the rest of the file if you like.

This is implemented by scanning for the subs you specify in the left column (permitting optional whitespace before it) and replacing it with a "use" declaration. Specifically, the call you see above would be turned into:

    use Call::Immediate::Call class Foo => sub {
        ...
    };

Where Call::Immedate::Call is a module that simply does nothing on import.

AUTHOR

Luke Palmer <lrpalmer at gmail dot com>