NAME
namespace - Perl pragma to use like C++ namespace aliasing
SYNOPSIS
my
$fh
= new File
"foo"
, O_CREAT|O_WRONLY;
if
(
defined
$fh
)
{
$fh
"bar\n"
;
$fh
->
close
;
}
DESCRIPTION
Allow aliasing namespace. May be useful for reusability increase.
[,
qw/IMPORT_LIST [ ::SUBPACKAGE [ IMPORT_LIST ]] /
];
ALIAS and PACKAGE is required parameters;
IMPORT_LIST is the usual list of
import
.
Also may be undefined namespace and they subnamespaces:
no
namespace ALIAS;
If ALIAS begin with '::', then alias will be expandet to caller namespace. If following example of pragma namespace called from main:: module, then alias will be expandet to main::ALIAS::.
EXAMPLES
EXAMPLE 1
# DOM is alias for XML::DOM
# $VERSION from XML::DOM will be imported to DOM
#
# ::Document subpackage of XML::DOM will be aliased to DOM::Document
# $VERSION from XML::DOM::Document will be imported to DOM::Document
my
$doc
= new DOM::Document;
"Current used DOM version is $DOM::VERSION \n"
;
no
namespace DOM;
# namespace DOM and all subnamespaces will be destroyed
EXAMPLE 2
# or
# use namespace DOM => XML::Sablotron::DOM, qw/:constants ::Document/;
my
$doc
= new DOM::Document;
"Constant 'TEXT_NODE' = "
, TEXT_NODE;
AUTHOR
Albert MICHEEV <amichauer@cpan.org>