Exporter::Attributes - Export symbols by attributes
version 0.002
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
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
@EXPORT
Exportable
Which adds the name of the symbol to EXPORT_OK
EXPORT_OK
The attributes accepts a list of tags as argument.
This is an ambivalent function. When called as Export::Attributes->import it just imports this "import" function into the namespace of the caller.
Export::Attributes->import
When called from any other class, it rewrites @EXPORT, @EXPORT_OK and @EXPORT_TAGS and let the rest of the work do by Exporter.
@EXPORT_OK
@EXPORT_TAGS
For overloading the import function, use this template:
sub import { # do some stuff, let @_ untouched goto &Exporter::Attributes::import; }
The tests in this distribution are copied from Exporter::Simple.
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.
David Zurborg <zurborg@cpan.org>
Marcel Gruenauer <marcel@cpan.org>
This software is Copyright (c) 2015 by David Zurborg.
This is free software, licensed under:
The ISC License
To install Exporter::Attributes, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Exporter::Attributes
CPAN shell
perl -MCPAN -e shell install Exporter::Attributes
For more information on module installation, please visit the detailed CPAN module installation guide.