NAME Package::Pkg - Handy package munging utilities VERSION version 0.0016 SYNOPSIS First, import a new keyword: "pkg" use Package::Pkg; Package name formation: pkg->name( 'Xy', 'A' ) # Xy::A pkg->name( $object, qw/ Cfg / ); # (ref $object)::Cfg 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 (literally sub import { ... }) 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 pkg->install( ... ) Install a subroutine, similar to Sub::Install (and actually using that module to do the dirty work) $package = pkg->name( , [ , ..., ] ) Return a namespace composed by joining each 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->name( 'Xy', 'A::', '::B' ) # Xy::A::B pkg->name( 'Xy', 'A::' ) # Xy::A:: { package Zy; pkg->name( '::', 'A::', '::B' ) # Zy::A::B pkg->name( '::Xy::A::B' ) # Zy::Xy::A::B } In addition, if any part is blessed, "name" will resolve that part to the package that the part makes reference to: my $object = bless {}, 'Xyzzy'; pkg->name( $object, qw/ Cfg / ); # Xyzzy::Cfg SEE ALSO Sub::Install Sub::Exporter AUTHOR Robert Krimen 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.