.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Exporter::Easy 3pm" .TH Exporter::Easy 3pm "2022-10-22" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Exporter::Easy \- Takes the drudgery out of Exporting symbols .SH "SYNOPSIS" .IX Header "SYNOPSIS" In module YourModule.pm: .PP .Vb 4 \& package YourModule; \& use Exporter::Easy ( \& OK => [ \*(Aq$munge\*(Aq, \*(Aqfrobnicate\*(Aq ] # symbols to export on request \& ); .Ve .PP In other files which wish to use YourModule: .PP .Vb 2 \& use ModuleName qw(frobnicate); # import listed symbols \& frobnicate ($left, $right) # calls YourModule::frobnicate .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Exporter::Easy makes using Exporter easy. In its simplest case, it allows you to drop the boilerplate code that comes with using Exporter, so .PP .Vb 4 \& require Exporter; \& use base qw( Exporter ); \& use vars qw( @EXPORT ); \& @EXPORT = ( \*(Aqinit\*(Aq ); .Ve .PP becomes .PP .Vb 1 \& use Exporter::Easy ( EXPORT => [ \*(Aqinit\*(Aq ] ); .Ve .PP and more complicated situations where you use tags to build lists and more tags become easy, like this .PP .Vb 12 \& use Exporter::Easy ( \& EXPORT => [qw( init :base )], \& TAGS => [ \& base => [qw( open close )], \& read => [qw( read sysread readline )], \& write => [qw( print write writeline )], \& misc => [qw( select flush )], \& all => [qw( :base :read :write :misc)], \& no_misc => [qw( :all !:misc )], \& ], \& OK => [qw( some other stuff )], \& ); .Ve .PP This will set \f(CW@EXPORT\fR, \f(CW@EXPORT_OK\fR, \f(CW@EXPORT_FAIL\fR and \f(CW%EXPORT_TAGS\fR in the current package, add Exporter to that package's \f(CW@ISA\fR and do a \&\f(CW\*(C`use vars\*(C'\fR on all the variables mentioned. The rest is handled as normal by Exporter. .SH "HOW TO USE IT" .IX Header "HOW TO USE IT" Put .PP .Vb 1 \& use Exporter::Easy ( KEY => value, ...); .Ve .PP in your package. Arguments are passes as key-value pairs, the following keys are available .IP "\s-1TAGS\s0" 4 .IX Item "TAGS" The value should be a reference to a list that goes like (\s-1TAG_NAME, TAG_VALUE, TAG_NAME, TAG_VALUE, ...\s0), where \s-1TAG_NAME\s0 is a string and \&\s-1TAG_VALUE\s0 is a reference to an array of symbols and tags. For example .Sp .Vb 7 \& TAGS => [ \& file => [ \*(Aqopen\*(Aq, \*(Aqclose\*(Aq, \*(Aqread\*(Aq, \*(Aqwrite\*(Aq], \& string => [ \*(Aqlength\*(Aq, \*(Aqsubstr\*(Aq, \*(Aqchomp\*(Aq ], \& hash => [ \*(Aqkeys\*(Aq, \*(Aqvalues\*(Aq, \*(Aqeach\*(Aq ], \& all => [ \*(Aq:file\*(Aq, \*(Aq:string\*(Aq, \*(Aq:hash\*(Aq ], \& some => [\*(Aq:all\*(Aq, \*(Aq!open\*(Aq, \*(Aq:hash\*(Aq], \& ] .Ve .Sp This is used to fill the \f(CW%EXPORT_TAGS\fR in your package. You can build tags from other tags \- in the example above the tag \f(CW\*(C`all\*(C'\fR will contain all the symbols from \f(CW\*(C`file\*(C'\fR, \f(CW\*(C`string\*(C'\fR and \f(CW\*(C`hash\*(C'\fR. You can also subtract symbols and tags \- in the example above, \f(CW\*(C`some\*(C'\fR contains the symbols from all but with \f(CW\*(C`open\*(C'\fR removed and all the symbols from \f(CW\*(C`hash\*(C'\fR removed. .Sp The rule is that any symbol starting with a ':' is taken to be a tag which has been defined previously (if it's not defined you'll get an error). If a symbol is preceded by a '!' it will be subtracted from the list, otherwise it is added. .Sp If you try to redefine a tag you will also get an error. .Sp All the symbols which occur while building the tags are automatically added your package's \f(CW@EXPORT_OK\fR array. .IP "\s-1OK\s0" 4 .IX Item "OK" The value should be a reference to a list of symbols and tags (which will be exapanded). These symbols will be added to the \f(CW@EXPORT_OK\fR array in your package. Using \s-1OK\s0 and and \s-1OK_ONLY\s0 together will give an error. .IP "\s-1OK_ONLY\s0" 4 .IX Item "OK_ONLY" The value should be a reference to a list of symbols and tags (which will be exapanded). The \f(CW@EXPORT_OK\fR array in your package will contains only these symbols.. This totally overrides the automatic population of this array. If you just want to add some symbols to the list that Exporter::Easy has automatically built then you should use \s-1OK\s0 instead. Using \s-1OK_ONLY\s0 and \s-1OK\s0 together will give an error. .IP "\s-1EXPORT\s0" 4 .IX Item "EXPORT" The value should be a reference to a list of symbol names and tags. Any tags will be expanded and the resulting list of symbol names will be placed in the \f(CW@EXPORT\fR array in your package. The tag created by the \s-1ALL\s0 key is not available at this stage. .IP "\s-1FAIL\s0" 4 .IX Item "FAIL" The value should be a reference to a list of symbol names and tags. The tags will be expanded and the resulting list of symbol names will be placed in the \f(CW@EXPORT_FAIL\fR array in your package. They will also be added to the \f(CW@EXPORT_OK\fR list. .IP "\s-1ALL\s0" 4 .IX Item "ALL" The value should be the name of tag that doesn't yet exist. This tag will contain a list of all symbols which can be exported. .IP "\s-1ISA\s0" 4 .IX Item "ISA" If you set this to 0 then Exporter will not be added to your \f(CW@ISA\fR list. .IP "\s-1VARS\s0" 4 .IX Item "VARS" If this is set to 1 or not provided then all $, @ and % variables mentioned previously will be available to use in your package as if you had done a \&\f(CW\*(C`use vars\*(C'\fR on them. If it's set to a reference to a list of symbols and tags then only those symbols will be available. If it's set to 0 then you'll have to do your own \f(CW\*(C`use vars\*(C'\fR in your package. .SH "PROCESSING ORDER" .IX Header "PROCESSING ORDER" We need take the information provided and build \f(CW@EXPORT\fR, \f(CW@EXPORT_OK\fR, \&\f(CW@EXPORT_FAIL\fR and \f(CW%EXPORT_TAGS\fR in the calling package. We may also need to build a tag with all of the symbols and to make all the variables useable under strict. .PP The arguments are processed in the following order: \s-1TAGS, EXPORT, OK, OK_ONLY\s0 and \s-1FAIL, ALL, VARS\s0 and finally \s-1ISA.\s0 This means you cannot use the tag created by \s-1ALL\s0 anywhere except in \s-1VARS\s0 (although vars defaults to using all symbols anyway). .SH "SEE ALSO" .IX Header "SEE ALSO" Exporter is the grandaddy of all Exporter modules, and bundled with Perl itself, unlike the rest of the modules listed here. Look at the documentation for this module to see more explanation of the \s-1OK, EXPORT\s0 and other variables. .PP Attribute::Exporter defines attributes which you use to mark which subs and variables you want to export, and how. .PP Exporter::Simple also uses attributes to control the export of functions and variables from your module. .PP Const::Exporter makes it easy to create a module that exports constants. .PP Constant::Exporter is another module that makes it easy to create modules that define and export constants. .PP Sub::Exporter is a \*(L"sophisticated exporter for custom-built routines\*(R"; it lets you provide generators that can be used to customise what gets imported when someone uses your module. .PP Exporter::Tiny provides the same features as Sub::Exporter, but relying only on core dependencies. .PP Exporter::Shiny is a shortcut for Exporter::Tiny that provides a more concise notation for providing optional exports. .PP Exporter::Declare provides syntactic sugar to make the export status of your functions part of their declaration. Kind of. .PP AppConfig::Exporter lets you export part of an AppConfig\-based configuration. .PP Exporter::Lexical lets you export lexical subs from your module. .PP Constant::Exporter::Lazy lets you write a module that exports function-style constants, which are instantiated lazily. .PP Exporter::Auto will export everything from your module that it thinks is a public function (name doesn't start with an underscore). .PP Class::Exporter lets you export class methods as regular subroutines. .PP Xporter is like Exporter, but with persistent defaults and auto-ISA. .SH "REPOSITORY" .IX Header "REPOSITORY" .SH "AUTHOR" .IX Header "AUTHOR" Written by Fergal Daly . .SH "LICENSE" .IX Header "LICENSE" Under the same license as Perl itself