NAME
UNIVERSAL::exports - Lightweight, universal exporting of variables
SYNOPSIS
package Foo;
use UNIVERSAL::exports;
# Just like Exporter.
@EXPORT = qw($This &That);
@EXPORT_OK = qw(@Left %Right);
# Meanwhile, in another piece of code!
package Bar;
use Foo; # exports $This and &That.
DESCRIPTION
This is an alternative to Exporter intended to provide a universal, lightweight subset of its functionality. It supports import
, @EXPORT
and @EXPORT_OK
and not a whole lot else.
Additionally, exports()
is provided to find out what symbols a module exports.
UNIVERSAL::exports places its methods in the UNIVERSAL namespace, so there is no need to subclass from it.
Methods
UNIVERSAL::exports has two public methods...
- import
-
Some::Module->import; Some::Module->import(@symbols);
Works just like
Exporter::import()
excepting it only honors @Some::Module::EXPORT and @Some::Module::EXPORT_OK.The given @symbols are exported to the current package provided they are in @Some::Module::EXPORT or @Some::Module::EXPORT_OK. Otherwise an exception is thrown (ie. the program dies).
If @symbols is not given, everything in @Some::Module::EXPORT is exported.
- exports
-
@exported_symbols = Some::Module->exports; Some::Module->exports($symbol);
Reports what symbols are exported by Some::Module. With no arguments, it simply returns a list of all exportable symbols. Otherwise, it reports if it will export a given $symbol.
DIAGNOSTICS
- '"%s" is not exported by the %s module'
-
Attempted to import a symbol which is not in @EXPORT or @EXPORT_OK.
- 'Can\'t export symbol: %s'
-
Attempted to import a symbol of an unknown type (ie. the leading $@% salad wasn't recognized).
AUTHORS
Michael G Schwern <schwern@pobox.com>
SEE ALSO
Exporter, UNIVERSAL::require, http://dev.perl.org/rfc/257.pod
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 160:
You forgot a '=back' before '=head1'