NAME
Package::Pkg - Handy package munging utilities
VERSION
version 0.0012
SYNOPSIS
First, import a new keyword: pkg
use Package::Pkg;
Subroutine installation:
pkg->install( sub { ... } => 'MyPackage::myfunction' );
# myfunction in MyPackage is now useable
MyPackage->myfunction( ... );
Subroutine exporting:
package MyPackage;
use Package::Pkg;
sub this { ... }
# Setup an exporter for MyPackage, exporting 'this' and 'that'
pkg->export( that => sub { ... }, 'this' );
package main;
use MyPackage;
this( ... );
that( ... );
DESCRIPTION
Package::Pkg is a collection of useful, miscellaneous package-munging utilities. Functionality is accessed via the imported pkg
keyword, although you can also invoke functions directly from the package (Package::Pkg
)
USAGE
install
Install a subroutine, similar to Sub::Install (and actually using that module to do the dirty work)
$package = package( <part>, [ <part>, ..., <part> ] )
Return a namespace composed by joining each <part> with ::
Superfluous/redundant ::
are automatically cleaned up and stripped from the resulting $package
If the first part leads with a ::
, the the calling package will be prepended to $package
pkg->package( 'Xyzzy', 'Apple::', '::Banana' ) # 'Xyzzy::Apple::Banana'
pkg->package( 'Xyzzy', 'Apple::' ) # 'Xyzzy::Apple::
package Cherry;
pkg->package( '::', 'Apple::', '::Banana' ) # 'Cherry::Apple::Banana'
pkg->package( '::Xyzzy::A::B' ) # 'Cherry::Xyzzy::A::B'
export( ... )
Setup an importer in the calling package
Under construction
SEE ALSO
AUTHOR
Robert Krimen <robertkrimen@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Robert Krimen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.