David Zurborg
and 2 contributors

NAME

Exporter::Attributes - Export symbols by attributes

VERSION

version 0.002

SYNOPSIS

    package FooBar;

    use Exporter::Attributes qw(import);

    sub Foo : Exported;
    sub Bar : Exportable;

    our $Cat : Exportable(vars);
    our $Dog : Exportable(vars);

    package main;

    use FooBar;           # import &Foo
    use FooBar qw(Bar);   # import &Bar
    use FooBar qw(:vars); # import $Cat and $Dog
    use FooBar qw(:all);  # import &Foo, &Bar, $Cat and $Dog

DESCRIPTION

This module is inspired by Exporter::Simple, but this module is broken since a long time. The new implementation uses a smarter way, by rewriting the caller's symbol table and then goto "import" in Exporter.

The list of the export symbols are captured with attributes. There are two attributes:

  • Exported

    Which adds the name of the symbol to @EXPORT

  • Exportable

    Which adds the name of the symbol to EXPORT_OK

The attributes accepts a list of tags as argument.

FUNCTIONS

import

This is an ambivalent function. When called as Export::Attributes->import it just imports this "import" function into the namespace of the caller.

When called from any other class, it rewrites @EXPORT, @EXPORT_OK and @EXPORT_TAGS and let the rest of the work do by Exporter.

For overloading the import function, use this template:

    sub import {
        # do some stuff, let @_ untouched
        goto &Exporter::Attributes::import;
    }

TESTS

The tests in this distribution are copied from Exporter::Simple.

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/zurborg/libexporter-attributes-perl/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHORS

  • David Zurborg <zurborg@cpan.org>

  • Marcel Gruenauer <marcel@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by David Zurborg.

This is free software, licensed under:

  The ISC License