<?xml version="1.0" encoding="windows-1252"?>
<node id="203" title="perlfunc:package" created="1999-08-24 18:42:04" updated="2005-08-15 14:35:35">
<type id="119">
perlfunc</type>
<author id="114">
gods</author>
<data>
<field name="doctext">
</field>
<field name="name">

&lt;P&gt;
package - declare a separate global namespace

&lt;P&gt;
&lt;HR&gt;
</field>
<field name="synopsis">

&lt;P&gt;
package 

&lt;P&gt;
package 
&lt;FONT SIZE=-1&gt;NAMESPACE&lt;/FONT&gt;

&lt;P&gt;
&lt;HR&gt;
</field>
<field name="description">

&lt;P&gt;
Declares the compilation unit as being in the given namespace. The scope of
the package declaration is from the declaration itself through the end of
the enclosing block (the same scope as the [perlfunc:local|local()] operator). All further unqualified dynamic identifiers will be in this namespace. 
&lt;FONT SIZE=-1&gt;A&lt;/FONT&gt; package statement affects only dynamic variables--including those you've used

[perlfunc:local|local()] on--but &lt;EM&gt;not&lt;/EM&gt; lexical variables created with [perlfunc:my|my()]. Typically it would be the first declaration in a file to be included by
the [perlfunc:require|require]
or [perlfunc:use|use] operator. You can switch into a package in more than one place; it merely
influences which symbol table is used by the compiler for the rest of that
block. You can refer to variables and filehandles in other packages by
prefixing the identifier with the package name and a double colon:  &lt;CODE&gt;$Package::Variable&lt;/CODE&gt;. If the package name is null, the &lt;CODE&gt;main&lt;/CODE&gt;
package as assumed. That is, &lt;CODE&gt;$::sail&lt;/CODE&gt; is equivalent to &lt;CODE&gt;$main::sail&lt;/CODE&gt;.

&lt;P&gt;
If 
&lt;FONT SIZE=-1&gt;NAMESPACE&lt;/FONT&gt; is omitted, then there is no current
package, and all identifiers must be fully qualified or lexicals. This is
stricter than &lt;CODE&gt;use strict&lt;/CODE&gt;, since it also extends to function names.

&lt;P&gt;
See [%linkNodeTitle "perlman:perlmod|Packages", $NODE, "Packages",{anchor=&gt;"Packages"};%] for more information about packages, modules, and classes. See [perlman:perlsub|the perlsub manpage] for other scoping issues.

&lt;HR&gt;
</field>
</data>
</node>
