The perl namespaces extension is designed as replacement of the standard means of declaring and importing symbols, such as the pragma use strict 'vars' and Exporter interface for modules. It makes the symbol lookup rules more similar to those in C++ :

Lexical variables (my) are not affected by this extension. our declarations are not compatible with the namespaces and should be avoided.

The global namespace main:: is purposely left aside as it contains many special variables (such as $_ or %ENV) which are automatically visible from all packages, and it would be absolutely silly to require them be explicitly declared. Some other special package-specific variables, such as @INC, $AUTOLOAD, or $a and $b in a sort block, may also be used without declaration.

Syntax

The namespace extension is implemented as a special compilation mode. It can be enabled and disabled for each lexical scope, just like use strict. Each package activated during the namespace compilation mode (with the package statement) is treated later as using namespaces, even if other parts of it are compiled in the standard, non-namespace mode. But mixing of both modes in one package is not a very good practice, as it could lead to unexpected exceptions caused by undeclared variables.

use namespaces; no namespaces;
Enables or disables the namespaces mode. The setting lasts up to the end of the current lexical scope. Note that the compilation of each source file starts with disabled namespace mode, even if the require or use statement which caused its inclusion lies in the namespace-enabled scope.
Enabling the namespace mode automatically implies no strict 'vars' and vice versa.
use namespaces 'AA', 'BB::CC', ...;
Enables the namespace mode and sets the import list for all packages defined later in the current lexical scope. This is the analogon of the C++ directive using namespace ... .
The importing relation between packages is transitive. For example, the lookup list for the packages compiled after the statement shown above will consist of AA, the packages imported by AA, BB::CC, the packages imported by BB::CC, BB, and the packages imported by BB. To avoid multiple searches, duplicates in the lookup list are removed immediately.
no namespaces 'AA', 'BB::CC', ...;
Removes the named packages from the current import list, but lets the namespace compilation mode active. Note that this change will affect only packages defined after this statement.

Effects at the run time

Each reference to a variable, both reading and writing, is first checked whether it refers to a declared or imported variable. If not, and the name is unqualified, then a declared variable with this name is looked up in all packages comprising the lookup list, as explained above. If found, the variable is imported into the current package. Otherwise, as well as when the variable name is qualified, an exception is raised.

The lookup operation is performed once per variable and package; the declaration check is performed once per variable and each expression (script line) using it which was ever executed. This way the performance penalty is constant and comparable to that of the traditional import mechanism.

Unqualified subroutine calls are resolved in the same manner, but in the case of a failure no special exception is raised, since it will be done by the perl interpreter itself. Taking a subroutine reference \&abc involves the lookup too. There is also a special function namespaces::lookup_sub('package_name', 'sub_name') returning the code reference or undef if the lookup fails.

eval '...' statements re-establish the namespace mode for the duration of the expression compilation.

namespaces in polymake

All rulefiles and perl modules defined in the application-specific perllib subdirectories are compiled with namespace mode enabled, due to the following statement automatically prepended to each source file:

use namespaces 'Apps::APPLICATION_NAME';

If an application imports polymake modules, their packages 'Modules::MODULE_NAME' are also included in the lookup list.

Finally, all applications and modules import everything from the package Poly, which contains some useful little functions like min and max.