NAME
ExportTo - export any function/method to any namespace
VERSION
Version 0.03
SYNOPSIS
package
From;
sub
function_1{
# ...
}
sub
function_2{
# ...
}
sub
function_3{
# ...
}
# Now, function_1 and function_2 are exported to 'NameSpace1' namespace.
# function_3 is exported to 'NameSpace2' namespace.
# If 'NameSpace1'/'NameSpace2' namespace has same name function/method,
# such a function/method is not exported and ExportTo croaks.
# but if you want to override, you can do it as following.
# if adding + to function/method name,
# This override function/method which namespace already has with exported function/method.
# if you add + to namespace name, all functions are exported even if namespace already has function/method.
# if using hashref instead of arrayref, its key is regarded as subroutine name and
# value is regarded as its coderef/subroutine name. and this subroutine name will be exported.
DESCRIPTION
This module allow you to export/override subroutine/method to one namespace. It can be used for mix-in, for extension of modules not using inheritance.
FUNCTION/METHOD
- export_to
-
# example 1 & 2
export_to(
PACKAGE_NAME
=> [
qw/FUNCTION_NAME/
]);
ExportTo->export_to(
PACKAGE_NAME
=> [
qw/FUNCTION_NAME/
]);
# example 3
ExportTo->export_to(
PACKAGE_NAME
=> {
SUBROUTINE_NAME
=>
sub
{ .... },
SUBROUTINE_NAME2
=>
'FUNCTION_NAME'
});
These are as same as following.
But, 'use' is needed to declare after declaration of function/method. using 'export_to', you can write anywhere.
Export from another package to another package (with renaming).
This is used in Util::Any. For example, CGI::Util's escape
function to other package.
Import from another package's subroutine to current package (with renaming)
It is as same as above.
But for this purpose, Sub::Import has better interface.
AUTHOR
Ktat, <ktat at cpan.org>
BUGS
Please report any bugs or feature requests to bug-exportto at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ExportTo. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc ExportTo
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
SEE ALSO
Sub::Import. If you import other module's function to current package, it is better than ExportTo.
COPYRIGHT & LICENSE
Copyright 2006-2009 Ktat, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.