Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Perl
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/Exporter
t
xt
.gitignore
Build.PL
Changes
LICENSE
META.json
README.md
cpanfile

README.md

NAME

Exporter::Auto - export all public functions from your package

SYNOPSIS

package Foo;
use Exporter::Auto;

sub foo { }

package main;
use Foo;
foo();  # <= this function was exported!

DESCRIPTION

Exporter::Auto is a simple replacement for Exporter that will export all public functions from your package. If you want all functions to be exported from your module by default, then this might be the module for you. If you only want some functions exported, or want tags, or to export variables, then you should look at one of the other Exporter modules ("SEE ALSO").

Let's say you have a library module with three functions, all of which you want to export by default. With Exporter, you'd write something like:

package MyLibrary;
use parent 'Exporter';
our @EXPORT = qw/ foo bar baz /;
sub foo { ... }
sub bar { ... }
sub baz { ... }
1;

Every time you add a new function, you must remember to add it to @EXPORT. Not a big hassle, but a small inconvenience.

With Exporter::Auto you just write:

package MyLibrary;
use Exporter::Auto;
sub foo { ... }
sub bar { ... }
sub baz { ... }
1;

When you use Exporter::Auto it automatically adds an import function to your package, so you don't need to declare your package as a subclass.

That's it. If you want anything more fancy than this, it's time for another module.

REPOSITORY

https://github.com/tokuhirom/Exporter-Auto

AUTHOR

Tokuhiro Matsuno

DEPENDENCIES

This module uses magical B::Hooks::EndOfScope. If you think this module is too clever, please try Module::Functions instead.

SEE ALSO

Exporter is the grandaddy of all Exporter modules, and bundled with Perl itself, unlike the rest of the modules listed here.

Sub::Exporter is a "sophisticated exporter for custom-built routines"; it lets you provide generators that can be used to customise what gets imported when someone uses your module.

Exporter::Tiny provides the same features as Sub::Exporter, but relying only on core dependencies.

Exporter::Declare provides Moose-style functions used to define what your module exports in a declarative way.

Exporter::Lite is a lightweight exporter module, falling somewhere between Exporter::Auto and Exporter.

LICENSE

Copyright (C) Tokuhiro Matsuno <TOKUHIROM @ GMAIL COM

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

Something went wrong with that request. Please try again.