NAME

Export::Declare - Declarative Exporting, successor of Exporter-Declare.

DESCRIPTION

Declare exports instead of using package vars. Successor to Exporter::Declare which was over complicated. Fully compatible with Importer and Exporter.

SYNOPSYS

DECLARING EXPORTS

package My::Exporter;
use Importer 'Export::Declare' => (qw/export exports export_tag export_meta/);

# You should do one of these, if you do not then 'vars' will be selected
# automatically.
export_meta->inject_menu; # Define IMPORTER_MENU
# and/or
export_meta->inject_vars; # Define @EXPORT and friends

# Export an anonymous sub
export foo => sub { 'foo' };

# Export package subs
exports qw/bar baz/;

# Default export
export_tag DEFAULT => qw/bat/;

# Define the subs you are exporting
sub bar { 'bar' }
sub baz { 'baz' }
sub bat { 'bat' }

CONSUMING EXPORTS

use Importer 'My::Exporter' => qw/foo bar baz bat/;

if the exporter imported import() from Export::Declare then you can use it directly, but this is discouraged.

use My::Exporter qw/foo bar baz bat/;

USE + IMPORT

You can use Export::Declare directly to bring in the tools. You can specify -menu and/or -vars to inject IMPORTER_MENU() and/or @EXPORT and friends.

use Export::Declare => qw/-vars -menu export exports/;

EXPORTS

All exports are optinal, none are exported by default.

DETAILS

This package tracks exports in a meta class. The meta-class is Export::Declare::Meta. All the exports act on the meta-object for the package that calls them. Having this meta-data on its own does not actually make your module an exporter, for that to happen you need to expose the meta-data in a way that Exporter or Importer know how to find it.

export_meta->inject_vars;
export_meta->inject_menu;

inject_vars will inject @EXPORT, @EXPORT_OK and other related vars. These vars will be directly linked to the meta-object.

inject_menu injects the IMPORTER_MENU() function that exposes the meta-data.

If you do not specify one, then vars will be selected for you automatically the first time you use an export function.

SOURCE

The source code repository for Export-Declare can be found at http://github.com/exodist/Export-Declare/.

MAINTAINERS

AUTHORS

COPYRIGHT

Copyright 2015 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/