Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Package::Alias
alias one namespace into another

Package::Alias - alias one namespace into another


NAME

Package::Alias - alias one namespace into another


SYNOPSIS


  use Package::Alias Foo    => 'main',

                     P      => 'Really::Long::Package::Name',

                     'A::B' => 'C::D',

                     Alias  => 'Existing::Namespace';


DESCRIPTION

This module aliases one package name to another. After running the SYNOPSIS code, @INC and @Foo::INC reference the same memory. $Really::Long::Package::Name::var and $P::var do as well.

To be strict-compliant, you'll need to quote any packages on the left-hand side of a => if the namespace has colons. Packages on the right-hand side all have to be quoted. This is documented as perlop/``Comma Operator''.

Chip Salzenberg says that it's not technically feasible to perform runtime namespace aliasing. At compile time, Perl grabs pointers to functions and global vars. Those pointers aren't updated if we alias the namespace at runtime.


GLOBALS

Package::Alias won't, by default, alias over a namespace if it's already in use. That's not considered a fatal error - you'll just get a warning and flow will continue. You can change that cowardly behaviour this way:


  # Make Bar like Foo, even if Bar is already in use.

  BEGIN { $Package::Alias::BRAVE = 1 }

  use Package::Alias Bar => 'Foo';


AUTHOR

Joshua Keroes <skunkworks@eli.net>


SEE ALSO

the Devel::Symdump manpage

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy