Giter Site home page Giter Site logo

exporter-auto's Introduction

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 <tokuhirom AAJKLFJEF@ GMAIL COM>

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.

exporter-auto's People

Contributors

tokuhirom avatar neilb avatar

Stargazers

Angus H. avatar Takuji Nishibayashi avatar Fayland Lam avatar  avatar Masaki Nakagawa avatar Tatsuhiko Miyagawa avatar

Watchers

 avatar  avatar James Cloos avatar  avatar

Forkers

neilb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.