Exporter::Tiny::Manual::QuickStart - Online Linux Manual PageSection : 3
Updated : 2021-01-27
Source : perl v5.32.1
Note : User Contributed Perl Documentation

NAMEExporter::Tiny::Manual::QuickStart − the quickest way to get up and running with Exporter::Tiny

SYNOPSIS​ package MyUtils; ​ ​ use Exporter::Shiny qw( frobnicate ); ​ ​ sub frobnicate { ​ ...; # your code here ​ } ​ ​ 1; Now people can use your module like this: ​ use MyUtils "frobnicate"; ​ ​ frobnicate(42); Or like this: ​ use MyUtils "frobnicate" => { −as => "frob" }; ​ ​ frob(42);

DESCRIPTIONSee the synopsis. Yes, it's that simple.

Next stepsDefault exports Note that the module in the synopsis doesn't export anything by default. If people load MyUtils like this: ​ use MyUtils; Then they haven't imported any functions. You can specify a default set of functions to be exported like this: ​ package MyUtils; ​ ​ use Exporter::Shiny qw( frobnicate ); ​ ​ our @EXPORT = qw( frobnicate ); ​ ​ sub frobnicate { ... } ​ ​ 1; Or, if you want to be a superstar rock god: ​ package MyUtils; ​ ​ use Exporter::Shiny our @EXPORT = qw( frobnicate ); ​ ​ sub frobnicate { ... } ​ ​ 1; Tags You can provide tags for people to use: ​ package MyUtils; ​ ​ use Exporter::Shiny qw( frobnicate red green blue ); ​ ​ our %EXPORT_TAGS = ( ​ utils => [qw/ frobnicate /], ​ colours => [qw/ red green blue /], ​ ); ​ ​ sub frobnicate { ... } ​ sub red { ... } ​ sub green { ... } ​ sub blue { ... } ​ ​ 1; And people can now import your functions like this: ​ use MyUtils ":colours"; Or this: ​ use MyUtils "−colours"; Or take advantage of the fact that Perl magically quotes barewords preceded by a hyphen: ​ use MyUtils −colours; Two tags are automatically defined for you: −default (which is just the same as @EXPORT) and −all (which is the union of ​@EXPORT and @EXPORT_OK). If you don't like them, then you can override them: ​ our %EXPORT_TAGS = ( ​ default => \@some_other_stuff, ​ all => \@more_stuff, ​ ); Generators Exporting normally just works by copying a sub from your package into your caller's package. But sometimes it's useful instead to generate a custom sub to insert into your caller's package. This is pretty easy to do. ​ package MyUtils; ​ ​ use Exporter::Shiny qw( frobnicate ); ​ ​ sub _generate_frobnicate { ​ my $me = shift; ​ my $caller = caller; ​ my ($name, $args) = @_; ​ ​ return sub { ​ ...; # your code here ​ }; ​ } ​ ​ 1; The parameter $me here is a string containing the package name which is being imported from; $caller is the destination package; ​$name is the name of the sub (in this case frobnicate); and ​$args is a hashref of custom arguments for this function. ​ # The hashref { foo => 42 } is $args above. ​ # ​ use MyUtils "frobnicate" => { foo => 42 };

Avoiding Exporter::ShinyExporter::Shiny is a tiny shim around Exporter::Tiny. It should mostly do what you want, but you may sometimes prefer to use Exporter::Tiny directly. The example in the synopsis could have been written as: ​ package MyUtils; ​ ​ use parent "Exporter::Tiny"; ​ our @EXPORT_OK = qw( frobnicate ); ​ ​ sub frobnicate { ​ ...; # your code here ​ } ​ ​ 1; What Exporter::Shiny does is mostly just to set @EXPORT_OK for you and set up inheritance from the base class (Exporter::Tiny). Exporter::Shiny also sets $INC{'MyUtils.pm} for you, which in usually makes little difference, but is useful in some edge cases.

SEE ALSOExporter::Shiny, Exporter::Tiny. For more advanced information, see Exporter::Tiny::Manual::Exporting.

AUTHORToby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCEThis software is copyright (c) 2013−2014, 2017 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIESTHIS PACKAGE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
0
Johanes Gumabo
Data Size   :   17,148 byte
man-Exporter::Tiny::Manual::QuickStart.3pmBuild   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 191,687
Visitor ID   :     :  
Visitor IP   :   18.191.72.220   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (parse_manual_page_|249|Exporter::Tiny::Manual::QuickStart.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\| )         (htmlprn|149|Exporter::Tiny::Manual::QuickStart.3pm|36/37|.el══─{─══. ds --  —  |.el══─{─══. ds -- \|\(em\| )         (parse_manual_page_|249|Exporter::Tiny::Manual::QuickStart.3pm|43|br══─}─══|'br══─}─══ )         (htmlprn|149|Exporter::Tiny::Manual::QuickStart.3pm|43|'br══─}─══ |'br══─}─══ )