Sub::Exporter 0.970 review
DownloadSub::Exporter is a sophisticated exporter for custom-built routines. SYNOPSIS Sub::Exporter must be used in two places
|
|
Sub::Exporter is a sophisticated exporter for custom-built routines.
SYNOPSIS
Sub::Exporter must be used in two places. First, in an exporting module:
# in the exporting module:
package Text::Tweaker;
use Sub::Exporter -setup => {
exports => [
qw(squish titlecase) # always works the same way
reformat => &build_reformatter, # generator to build exported function
trim => &build_trimmer,
indent => &build_indenter,
],
collectors => [ 'defaults' ],
};
Then, in an importing module:
# in the importing module:
use Text::Tweaker
'squish',
indent => { margin => 5 },
reformat => { width => 79, justify => 'full', -as => 'prettify_text' },
defaults => { eol => 'CRLF' };
With this setup, the importing module ends up with three routines: squish, indent, and prettify_text. The latter two have been built to the specifications of the importer -- they are not just copies of the code in the exporting package.
Requirements:
Perl
Sub::Exporter 0.970 keywords