Ben Morrow > Exporter-NoWork > Exporter::NoWork

Download:
Exporter-NoWork-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Exporter::NoWork - an easier way to export functions

SYNOPSIS ^

    package MyPack;

    use Exporter::NoWork -CONSTS => qw/default/;

    sub default {
        # this is exported by default
    }

    sub public {
        # this is exported on request
    }

    sub _private {
        # this is not exported
    }

    sub A_CONSTANT {
        # this is exported by default
    }

    sub tagged :Tag(tag) {
        # this is exported on the tag :tag
    }

DESCRIPTION ^

There is no need to add Exporter::NoWork to your @ISA: the use statement will do that for you. All functions are considered exportable, except those beginning with an underscore, unless the option -MAGIC is given on the use line in which case functions with names in ALL CAPS are not exportable either.

The arguments given on the use line form the default import list. If the option -CONSTS is given, all subs whose names consist of only upper-case letters, digits and underscores will be added to the default list as well.

Tags can be defined by giving subs the :Tag(tagname) attribute. The argument for the attribute should be a comma-separated list of tag names to associate this sub with. Additional tags created are:

:ALL

All exportable functions.

:DEFAULT

Those functions that would have been exported by default.

:CONSTS

If the -CONSTS option was given the Exporter::NoWork, this consists of all the subs added to :DEFAULT as a result of that.

In addition, any arguments given to your module which begin with a '-' are considered to be configuration options. Exporter::NoWork will first check the global hash %CONFIG in your package for a sub to call, and if that fails try calling the method CONFIG in your package. In both cases the sub will receive three arguments: your own package name, the option name (with '-' stripped), and a reference to an array with the rest of the arguments to your module. This is so you can shift off some entries if your option should take arguments.

If your module defines a method IMPORT, this will be called before anything else is done but after the default export list has been substituted if necessary. This is expected to return a list of symbols to export.

AUTHOR ^

Ben Morrow <ben@morrow.me.uk>

Please report bugs at rt.cpan.org.

COPYRIGHT ^

Copyright 2004 Ben Morrow. This module may be distributed under the same terms as Perl.

syntax highlighting: