Полезная информация

Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: Reference: packChapter 5
Function Reference
Next: Reference: pipe
 

package

package namespace

Declares that the rest of the innermost enclosing block, subroutine, eval or file belongs to the indicated namespace. (The scope of a package declaration is thus the same as the scope of a local or my declaration.) All subsequent references to unqualified global identifiers will be resolved by looking them up in the declared packages symbol table. A package declaration affects only global variables - including those you've used local on - but not lexical variables created with my.

Typically you would put a package declaration as the first thing in a file that is to be included by the require or use 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.)


Previous: Reference: packPerl in a NutshellNext: Reference: pipe
Reference: packBook IndexReference: pipe