UNIVER...xports(3pm)
π UNIVERSAL::exports π
okay so bestie, welcome to UNIVERSAL::exports β the lightweight, universal exporting of variables situation. It's a Perl module (a 3pm one, iykyk) and it lives in the User Contributed Perl Documentation corner of your system. Let's get into it β¨
πΈ 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.
likeβ¦ you set up @EXPORT and @EXPORT_OK exactly the way you already know and love, and then the other package just uses you and gets the goods. periodt. π
π¦ DESCRIPTION π¦
So here's the tea: this is an alternative to Exporter that's meant to give you a universal, lightweight subset of what Exporter does. It leans on Exporter::Lite, so if you want the deets on how that all works, go look there π.
On top of all that, it also hands you exports() so you can find out what symbols a module exports. Very demure. Very mindful. π
And the iconic part? UNIVERSAL::exports puts its methods in the UNIVERSAL namespace, so there is literally no need to subclass from it. Not me avoiding inheritance π.
β¨ Methods β¨
UNIVERSAL::exports has two public methods: import() (which is derived from Exporter::Lite) and exports().
π import
Some::Module->import;
Some::Module->import(@symbols);
This is Exporter::Lite's import() method, bestie. Look in Exporter::Lite for details. π«Ά
π exports
@exported_symbols = Some::Module->exports;
Some::Module->exports($symbol);
This one reports what symbols are exported by Some::Module. With no arguments, it just returns a list of all exportable symbols. Otherwise? It reports whether it will export a given $symbol. Very useful, very slay. π
π DIAGNOSTICS π
'"%s" is not exported by the %s module'β you tried to import a symbol that is not in@EXPORTor@EXPORT_OK. Rude of you, honestly π.'Can\'t export symbol: %s'β you tried to import a symbol of an unknown type, aka the leading$@%salad wasn't recognized π₯π.
π AUTHORS π
Michael G Schwern <schwern@pobox.com>
an absolute legend, fr fr. β¨
π BUGS and ISSUES π
Please report bugs and issues via <http://rt.cpan.org> β the RT queue is right there, use it, bestie. π
π LICENSE and COPYRIGHT π
Copyright 2001, 2006 Michael G Schwern
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/perl/misc/Artistic.html>
fr fr, it's free software β same terms as Perl itself, no cap. π
π«Ά SEE ALSO π«Ά
- Other ways to Export:
Exporter,Exporter::Lite,Sub::Exporter,Exporter::Simple - The Perl 6 RFC that started it all: <http://dev.perl.org/rfc/257.pod>
- More UNIVERSAL magic:
UNIVERSAL::require
the way that RFC 257 started a whole thingβ¦ iconic behavior. π
okay that's the whole page, bestie!! this was perl v5.36.0, dated 2022-11-19, and it came from the UNIVER...xports(3pm) page in the User Contributed Perl Documentation. mwah π go export something slay today β¨πΈπ¦
π¦ where this page comes from
- debian bookworm: libuniversal-exports-perl 0.05-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libuniversal-exports-perl 0.05-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms