English     Español
[Main Index] : Programming : Languages : Perl : CPAN Modules : Others
 namespace CPAN (Perl) Module 

Search

 

Documents

namespace - Perl pragma to use like C++ namespace aliasing (Displayed)

namespace - Perl pragma to use like C++ namespace aliasing


NAME

namespace - Perl pragma to use like C++ namespace aliasing


SYNOPSIS

 use namespace File => IO::File;
 my $fh = new File "foo", O_CREAT|O_WRONLY;
 if( defined $fh )
 {
     print $fh "bar\n";
     $fh->close;
 }


DESCRIPTION

Allow aliasing namespace. May be useful for reusability increase.

 use namespace ALIAS => PACKAGE 
    [, 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::.


 use namespace ::ALIAS => PACKAGE


EXAMPLES

 EXAMPLE 1
 use namespace DOM => XML::DOM, qw/$VERSION ::Document $VERSION/;
    # 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;
 print "Current used DOM version is $DOM::VERSION \n";
 no namespace DOM;
    # namespace DOM and all subnamespaces will be destroyed
 EXAMPLE 2
 use namespace DOM => XML::DOM, qw/::Document/;
 # or
 # use namespace DOM => XML::Sablotron::DOM, qw/:constants ::Document/;
 my $doc = new DOM::Document;
 print "Constant 'TEXT_NODE' = ", TEXT_NODE;


AUTHOR

Albert MICHEEV <amichauer@cpan.org>

Information

This site is currently in testing, it is not yet operating using the full database. Until it is officially launched you may wish to visit Help-Site Computer Manuals. After launch, this site (HelpSpy) will replace Help-Site. Information about the spider which is currently trawling the Internet looking for links to add to this directory can be found here.
   

©Copyright Nicholas Reynolds 2004