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       Exporter::Lite simply exports its import() function into your
30       namespace.  This might be called a "mix-in" or a "role".
31
32       When "Exporter::Lite" was written, if you wanted to use "Exporter" you
33       had to write something like this:
34
35        use Exporter;
36        our @ISA = qw/ Exporter /;
37
38       "Exporter::Lite" saved you from writing that second line.  But since
39       before 2010 you've been able to write:
40
41        use Exporter qw/ import /;
42
43       Which imports the "import" function into your namespace from
44       "Exporter".  As a result, I would recommend that you use "Exporter"
45       now, as it's a core module (shipped with Perl).
46
47       To make sure you get a version of "Exporter" that supports the above
48       usage, specify a minimum version when you "use" it:
49
50        use Exporter 5.57 qw/ import /;
51
52   Back to "Exporter::Lite"
53       Setting up a module to export its variables and functions is simple:
54
55           package My::Module;
56           use Exporter::Lite;
57
58           our @EXPORT = qw($Foo bar);
59
60       Functions and variables listed in the @EXPORT package variable are
61       automatically exported if you use the module and don't explicitly list
62       any imports.  Now, when you "use My::Module", $Foo and bar() will show
63       up.
64
65       Optional exports are listed in the @EXPORT_OK package variable:
66
67           package My::Module;
68           use Exporter::Lite;
69
70           our @EXPORT_OK = qw($Foo bar);
71
72       When My::Module is used, $Foo and bar() will not show up, unless you
73       explicitly ask for them:
74
75           use My::Module qw($Foo bar);
76
77       Note that when you specify one or more functions or variables to
78       import, then you must also explicitly list any of the default symbols
79       you want to use.  So if you have an exporting module:
80
81           package Games;
82           our @EXPORT    = qw/ pacman defender  /;
83           our @EXPORT_OK = qw/ galaga centipede /;
84
85       Then if you want to use both "pacman" and "galaga", then you'd write:
86
87           use Games qw/ pacman galaga /;
88

Methods

90       Export::Lite has one public method, import(), which is called
91       automatically when your modules is use()'d.
92
93       In normal usage you don't have to worry about this at all.
94
95       import
96             Some::Module->import;
97             Some::Module->import(@symbols);
98
99           Works just like Exporter::import() excepting it only honors
100           @Some::Module::EXPORT and @Some::Module::EXPORT_OK.
101
102           The given @symbols are exported to the current package provided
103           they are in @Some::Module::EXPORT or @Some::Module::EXPORT_OK.
104           Otherwise an exception is thrown (ie. the program dies).
105
106           If @symbols is not given, everything in @Some::Module::EXPORT is
107           exported.
108

DIAGNOSTICS

110       '"%s" is not exported by the %s module'
111           Attempted to import a symbol which is not in @EXPORT or @EXPORT_OK.
112
113       'Can\'t export symbol: %s'
114           Attempted to import a symbol of an unknown type (ie. the leading
115           $@% salad wasn't recognized).
116

SEE ALSO

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

REPOSITORY

162       <https://github.com/neilb/Exporter-Lite>
163

AUTHORS

165       Michael G Schwern <schwern@pobox.com>
166

LICENSE

168       This program is free software; you can redistribute it and/or modify it
169       under the same terms as Perl itself.
170
171       See http://www.perl.com/perl/misc/Artistic.html
172
173
174
175perl v5.38.0                      2023-07-20                 Exporter::Lite(3)
Impressum