package
package namespace
- Declares that the rest of the innermost enclosing block, subroutine,
eval
or file belongs to the indicated namespace. (The scope of apackage
declaration is thus the same as the scope of alocal
ormy
declaration.) All subsequent references to unqualified global identifiers will be resolved by looking them up in the declared packages symbol table. Apackage
declaration affects only global variables - including those you've usedlocal
on - but not lexical variables created withmy
.Typically you would put a
package
declaration as the first thing in a file that is to be included by therequire
oruse
operator, but you can put one anywhere that a statement would be legal. When defining a class or a module file, it is customary to name the package the same name as the file, to avoid confusion. (It's also customary to name such packages beginning with a capital letter, because lowercase modules are, by convention, interpreted as pragmas.)