1Exporter::Lite(3)     User Contributed Perl Documentation    Exporter::Lite(3)
2
3
4

NAME

6       Exporter::Lite - lightweight exporting of functions and variables
7

SYNOPSIS

9         package Foo;
10         use Exporter::Lite;
11
12         our @EXPORT    = qw($This That);      # default exports
13         our @EXPORT_OK = qw(@Left %Right);    # optional exports
14
15       Then in code using the module:
16
17         use Foo;
18         # $This and &That are imported here
19
20       You have to explicitly ask for optional exports:
21
22        use Foo qw/ @Left %Right /;
23

DESCRIPTION

25       Exporter::Lite is an alternative to Exporter, intended to provide a
26       lightweight subset of the most commonly-used functionality.  It
27       supports "import()", @EXPORT and @EXPORT_OK and not a whole lot else.
28
29       Unlike Exporter, it is not necessary to inherit from Exporter::Lite; Ie
30       you don't need to write:
31
32        @ISA = qw(Exporter::Lite);
33
34       Exporter::Lite simply exports its import() function into your
35       namespace.  This might be called a "mix-in" or a "role".
36
37       Setting up a module to export its variables and functions is simple:
38
39           package My::Module;
40           use Exporter::Lite;
41
42           our @EXPORT = qw($Foo bar);
43
44       Functions and variables listed in the @EXPORT package variable are
45       automatically exported if you use the module and don't explicitly list
46       any imports.  Now, when you "use My::Module", $Foo and "bar()" will
47       show up.
48
49       Optional exports are listed in the @EXPORT_OK package variable:
50
51           package My::Module;
52           use Exporter::Lite;
53
54           our @EXPORT_OK = qw($Foo bar);
55
56       When My::Module is used, $Foo and "bar()" will not show up, unless you
57       explicitly ask for them:
58
59           use My::Module qw($Foo bar);
60
61       Note that when you specify one or more functions or variables to
62       import, then you must also explicitly list any of the default symbols
63       you want to use.  So if you have an exporting module:
64
65           package Games;
66           our @EXPORT    = qw/ pacman defender  /;
67           our @EXPORT_OK = qw/ galaga centipede /;
68
69       Then if you want to use both "pacman" and "galaga", then you'd write:
70
71           use Games qw/ pacman galaga /;
72

Methods

74       Export::Lite has one public method, import(), which is called
75       automatically when your modules is use()'d.
76
77       In normal usage you don't have to worry about this at all.
78
79       import
80             Some::Module->import;
81             Some::Module->import(@symbols);
82
83           Works just like "Exporter::import()" excepting it only honors
84           @Some::Module::EXPORT and @Some::Module::EXPORT_OK.
85
86           The given @symbols are exported to the current package provided
87           they are in @Some::Module::EXPORT or @Some::Module::EXPORT_OK.
88           Otherwise an exception is thrown (ie. the program dies).
89
90           If @symbols is not given, everything in @Some::Module::EXPORT is
91           exported.
92

DIAGNOSTICS

94       '"%s" is not exported by the %s module'
95           Attempted to import a symbol which is not in @EXPORT or @EXPORT_OK.
96
97       'Can\'t export symbol: %s'
98           Attempted to import a symbol of an unknown type (ie. the leading
99           $@% salad wasn't recognized).
100

SEE ALSO

102       Exporter is the grandaddy of all Exporter modules, and bundled with
103       Perl itself, unlike the rest of the modules listed here.
104
105       Attribute::Exporter defines attributes which you use to mark which subs
106       and variables you want to export, and how.
107
108       Exporter::Simple also uses attributes to control the export of
109       functions and variables from your module.
110
111       Const::Exporter makes it easy to create a module that exports
112       constants.
113
114       Constant::Exporter is another module that makes it easy to create
115       modules that define and export constants.
116
117       Sub::Exporter is a "sophisticated exporter for custom-built routines";
118       it lets you provide generators that can be used to customise what gets
119       imported when someone uses your module.
120
121       Exporter::Tiny provides the same features as Sub::Exporter, but relying
122       only on core dependencies.
123
124       Exporter::Shiny is a shortcut for Exporter::Tiny that provides a more
125       concise notation for providing optional exports.
126
127       Exporter::Declare provides syntactic sugar to make the export status of
128       your functions part of their declaration. Kind of.
129
130       AppConfig::Exporter lets you export part of an AppConfig-based
131       configuration.
132
133       Exporter::Lexical lets you export lexical subs from your module.
134
135       Constant::Export::Lazy lets you write a module that exports function-
136       style constants, which are instantiated lazily.
137
138       Exporter::Auto will export everything from your module that it thinks
139       is a public function (name doesn't start with an underscore).
140
141       Class::Exporter lets you export class methods as regular subroutines.
142
143       Xporter is like Exporter, but with persistent defaults and auto-ISA.
144

REPOSITORY

146       <https://github.com/neilb/Exporter-Lite>
147

AUTHORS

149       Michael G Schwern <schwern@pobox.com>
150

LICENSE

152       This program is free software; you can redistribute it and/or modify it
153       under the same terms as Perl itself.
154
155       See http://www.perl.com/perl/misc/Artistic.html
156
157
158
159perl v5.28.0                      2016-01-13                 Exporter::Lite(3)
Impressum