%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/opti/optisoftcom-new/perl/usr/man/man3/
Upload File :
Create Path :
Current File : /home/opti/optisoftcom-new/perl/usr/man/man3/Exporter::Tiny::Manual::Exporting.3pm

.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" 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 turned on, 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
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Exporter::Tiny::Manual::Exporting 3"
.TH Exporter::Tiny::Manual::Exporting 3 "2018-07-17" "perl v5.16.3" "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::Tiny::Manual::Exporting \- creating an exporter using Exporter::Tiny
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
\&\fBRead Exporter::Tiny::Manual::QuickStart first!\fR
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Simple configuration works the same as Exporter; inherit from
Exporter::Tiny, and use the \f(CW@EXPORT\fR, \f(CW@EXPORT_OK\fR,
and \f(CW%EXPORT_TAGS\fR package variables to list subs to export.
.PP
Unlike Exporter, Exporter::Tiny performs most of its internal duties
(including resolution of tag names to sub names, resolution of sub
names to coderefs, and installation of coderefs into the target
package) as \fBmethod calls\fR, which means that your module (which is a
subclass of Exporter::Tiny) can override them to provide interesting
behaviour.
.SS "Advanced Tag Stuff"
.IX Subsection "Advanced Tag Stuff"
You can define tags using other tags:
.PP
.Vb 3
\&   use Exporter::Shiny qw(
\&      black white red green blue cyan magenta yellow
\&   );
\&   
\&   our %EXPORT_TAGS = (
\&      rgb        => [qw( red green blue )],
\&      cym        => [qw( cyan magenta yellow )],
\&      cymk       => [qw( black :cym )],
\&      monochrome => [qw( black white )],
\&      all        => [qw( :rgb :cymk :monochrome )],
\&   );
.Ve
.PP
\&\fB\s-1CAVEAT:\s0\fR If you create a cycle in the tags, this could put
Exporter::Tiny into an infinite loop expanding the tags. Don't do that.
.SS "More on Generators"
.IX Subsection "More on Generators"
Exporter::Tiny has always allowed exported subs to be generated (like
Sub::Exporter), but until version 0.025 did not have an especially nice
\&\s-1API\s0 for it.
.PP
Now, it's easy. If you want to generate a sub \f(CW\*(C`foo\*(C'\fR to export, list it in
\&\f(CW@EXPORT\fR or \f(CW@EXPORT_OK\fR as usual, and then simply give your
exporter module a class method called \f(CW\*(C`_generate_foo\*(C'\fR.
.PP
.Vb 1
\&   push @EXPORT_OK, \*(Aqfoo\*(Aq;
\&   
\&   sub _generate_foo {
\&      my $class = shift;
\&      my ($name, $args, $globals) = @_;
\&      
\&      return sub {
\&         ...;
\&      }
\&   }
.Ve
.PP
We showed how to do that in Exporter::Tiny::Manual::QuickStart, but
one thing we didn't show was that \f(CW$globals\fR gets passed in there.
This is the global options hash, as described in
Exporter::Tiny::Manual::Importing. It can often be useful. In
particular it will tell you what package the generated sub is destined
to be installed into.
.PP
To generate non-code symbols, name your generators like this:
.PP
.Vb 3
\&  sub _generateScalar_Foo { ... }  # generate a symbol $Foo
\&  sub _generateArray_Bar  { ... }  # generate a symbol @Bar
\&  sub _generateHash_Baz   { ... }  # generate a symbol %Baz
.Ve
.PP
You can also generate tags:
.PP
.Vb 5
\&   my %constants;
\&   BEGIN {
\&      %constants = (FOO => 1, BAR => 2);
\&   }
\&   use constant \e%constants;
\&   
\&   $EXPORT_TAGS{constants} = sub {
\&      my $class = shift;
\&      my ($name, $args, $globals) = @_;
\&      
\&      return keys(%constants);
\&   };
.Ve
.SS "Hooks"
.IX Subsection "Hooks"
Sometimes as well as exporting stuff, you want to do some setup or
something.
.PP
You can define a couple of class methods in your package, and they'll
get called at the appropriate time:
.PP
.Vb 1
\&   package MyUtils;
\&   
\&   ...;
\&   
\&   sub _exporter_validate_opts {
\&      my $class = shift;
\&      my ($globals) = @_;
\&      
\&      ...;   # do stuff here
\&      
\&      $class\->SUPER::_exporter_validate_opts(@_);
\&   }
\&   
\&   sub _exporter_validate_unimport_opts {
\&      my $class = shift;
\&      my ($globals) = @_;
\&      
\&      ...;   # do stuff here
\&      
\&      $class\->SUPER::_exporter_validate_unimport_opts(@_);
\&   }
.Ve
.PP
The \f(CW$globals\fR variable is that famous global options hash. In
particular, \f(CW\*(C`$globals\->{into}\*(C'\fR is useful because it tells you what
package has imported you.
.PP
As you might have guessed, these methods were originally intended to
validate the global options hash, but can be used to perform any
general duties before the real exporting work is done.
.SS "Overriding Internals"
.IX Subsection "Overriding Internals"
An important difference between Exporter and Exporter::Tiny is that
the latter calls all its internal functions as \fIclass methods\fR. This
means that your subclass can \fIoverride them\fR to alter their behaviour.
.PP
The following methods are available to be overridden. Despite being named
with a leading underscore, they are considered public methods. (The underscore
is there to avoid accidentally colliding with any of your own function names.)
.ie n .IP """_exporter_validate_opts($globals)""" 4
.el .IP "\f(CW_exporter_validate_opts($globals)\fR" 4
.IX Item "_exporter_validate_opts($globals)"
Documented above.
.ie n .IP """_exporter_validate_unimport_opts($globals)""" 4
.el .IP "\f(CW_exporter_validate_unimport_opts($globals)\fR" 4
.IX Item "_exporter_validate_unimport_opts($globals)"
Documented above.
.ie n .IP """_exporter_merge_opts($tag_opts, $globals, @exports)""" 4
.el .IP "\f(CW_exporter_merge_opts($tag_opts, $globals, @exports)\fR" 4
.IX Item "_exporter_merge_opts($tag_opts, $globals, @exports)"
Called to merge options which have been provided for a tag into the
options provided for the exports that the tag expanded to.
.ie n .IP """_exporter_expand_tag($name, $args, $globals)""" 4
.el .IP "\f(CW_exporter_expand_tag($name, $args, $globals)\fR" 4
.IX Item "_exporter_expand_tag($name, $args, $globals)"
This method is called to expand an import tag (e.g. \f(CW":constants"\fR).
It is passed the tag name (minus the leading \*(L":\*(R"), an optional hashref
of options (like \f(CW\*(C`{ \-prefix => "foo_" }\*(C'\fR), and the global options
hashref.
.Sp
It is expected to return a list of ($name, \f(CW$args\fR) arrayref pairs. These
names can be sub names to export, or further tag names (which must have
their \*(L":\*(R"). If returning tag names, be careful to avoid creating a tag
expansion loop!
.Sp
The default implementation uses \f(CW%EXPORT_TAGS\fR to expand tags, and
provides fallbacks for the \f(CW\*(C`:default\*(C'\fR and \f(CW\*(C`:all\*(C'\fR tags.
.ie n .IP """_exporter_expand_regexp($regexp, $args, $globals)""" 4
.el .IP "\f(CW_exporter_expand_regexp($regexp, $args, $globals)\fR" 4
.IX Item "_exporter_expand_regexp($regexp, $args, $globals)"
Like \f(CW\*(C`_exporter_expand_regexp\*(C'\fR, but given a regexp-like string instead
of a tag name.
.Sp
The default implementation greps through \f(CW@EXPORT_OK\fR for imports,
and the list of already-imported functions for exports.
.ie n .IP """_exporter_expand_sub($name, $args, $globals)""" 4
.el .IP "\f(CW_exporter_expand_sub($name, $args, $globals)\fR" 4
.IX Item "_exporter_expand_sub($name, $args, $globals)"
This method is called to translate a sub name to a hash of name => coderef
pairs for exporting to the caller. In general, this would just be a hash with
one key and one value, but, for example, Type::Library overrides this
method so that \f(CW"+Foo"\fR gets expanded to:
.Sp
.Vb 6
\&   (
\&      Foo         => sub { $type },
\&      is_Foo      => sub { $type\->check(@_) },
\&      to_Foo      => sub { $type\->assert_coerce(@_) },
\&      assert_Foo  => sub { $type\->assert_return(@_) },
\&   )
.Ve
.Sp
The default implementation checks that the name is allowed to be exported
(using the \f(CW\*(C`_exporter_permitted_regexp\*(C'\fR method), gets the coderef using
the generator if there is one (or by calling \f(CW\*(C`can\*(C'\fR on your exporter
otherwise) and calls \f(CW\*(C`_exporter_fail\*(C'\fR if it's unable to generate or
retrieve a coderef.
.Sp
Despite the name, is also called for non-code symbols.
.ie n .IP """_exporter_permitted_regexp($globals)""" 4
.el .IP "\f(CW_exporter_permitted_regexp($globals)\fR" 4
.IX Item "_exporter_permitted_regexp($globals)"
This method is called to retrieve a regexp for validating the names of
exportable subs. If a sub doesn't match the regexp, then the default
implementation of \f(CW\*(C`_exporter_expand_sub\*(C'\fR will refuse to export it. (Of
course, you may override the default \f(CW\*(C`_exporter_expand_sub\*(C'\fR.)
.Sp
The default implementation of this method assembles the regexp from
\&\f(CW@EXPORT\fR and \f(CW@EXPORT_OK\fR.
.ie n .IP """_exporter_fail($name, $args, $globals)""" 4
.el .IP "\f(CW_exporter_fail($name, $args, $globals)\fR" 4
.IX Item "_exporter_fail($name, $args, $globals)"
Called by \f(CW\*(C`_exporter_expand_sub\*(C'\fR if it can't find a coderef to export.
.Sp
The default implementation just throws an exception. But you could emit
a warning instead, or just ignore the failed export.
.Sp
If you don't throw an exception then you should be aware that this
method is called in list context, and any list it returns will be treated
as an \f(CW\*(C`_exporter_expand_sub\*(C'\fR\-style hash of names and coderefs for
export.
.ie n .IP """_exporter_install_sub($name, $args, $globals, $coderef)""" 4
.el .IP "\f(CW_exporter_install_sub($name, $args, $globals, $coderef)\fR" 4
.IX Item "_exporter_install_sub($name, $args, $globals, $coderef)"
This method actually installs the exported sub into its new destination.
Its return value is ignored.
.Sp
The default implementation handles sub renaming (i.e. the \f(CW\*(C`\-as\*(C'\fR,
\&\f(CW\*(C`\-prefix\*(C'\fR and \f(CW\*(C`\-suffix\*(C'\fR functions. This method does a lot of
stuff; if you need to override it, it's probably a good idea to just
pre-process the arguments and then call the super method rather than
trying to handle all of it yourself.
.Sp
Despite the name, is also called for non-code symbols.
.ie n .IP """_exporter_uninstall_sub($name, $args, $globals)""" 4
.el .IP "\f(CW_exporter_uninstall_sub($name, $args, $globals)\fR" 4
.IX Item "_exporter_uninstall_sub($name, $args, $globals)"
The opposite of \f(CW\*(C`_exporter_install_sub\*(C'\fR.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Exporter::Shiny,
Exporter::Tiny.
.SH "AUTHOR"
.IX Header "AUTHOR"
Toby Inkster <tobyink@cpan.org>.
.SH "COPYRIGHT AND LICENCE"
.IX Header "COPYRIGHT AND LICENCE"
This software is copyright (c) 2013\-2014, 2017 by Toby Inkster.
.PP
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
.SH "DISCLAIMER OF WARRANTIES"
.IX Header "DISCLAIMER OF WARRANTIES"
\&\s-1THIS PACKAGE IS PROVIDED \*(L"AS IS\*(R" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.\s0

Zerion Mini Shell 1.0