📄 ch03_03.htm
字号:
<html><head><title>Environment Variables (Perl in a Nutshell, 2nd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Stephen Spainhour" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly & Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596002416L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Perl in a Nutshell, 2nd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Java and XSLT" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch03_02.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch03_04.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">3.3. Environment Variables</h2><p><a name="INDEX-161" />Environment variables are used to setuser preferences. Individual Perl modules or programs are always freeto define their own environment variables, and there is also a set ofspecial environment variables used in the CGI environment (see <a href="ch09_01.htm">Chapter 9, "CGI Overview"</a>). </p><p>Perl uses the following environment variables:</p><dl><dt><i>HOME</i></dt><dd>Used if <tt class="literal">chdir</tt> has noargument<a name="INDEX-162" />.</p></dd><dt><i>LOGDIR</i></dt><dd>Used if <tt class="literal">chdir</tt> has no argument and HOME is notset<a name="INDEX-163" />.</p></dd><dt><i>PATH</i></dt><dd>Used in executing subprocesses and in finding the script if<em class="emphasis">-S</em> is used<a name="INDEX-164" />.</p></dd><dt><i>PATHEXT</i></dt><dd>On Win32 systems, if you want to avoid typing the extension everytime you execute a Perl script, you can set the PATHEXT environmentvariable <a name="INDEX-165" />sothat it includes Perl scripts. For example:</p><blockquote><pre class="code">C:\> set PATHEXT=%PATHEXT%;.PLX</pre></blockquote><p>This setting lets you type: </p><blockquote><pre class="code">C:\> myscript</pre></blockquote><p>without including the file extension. Be careful when setting PATHEXTpermanently—it also includes executable file types such as<em class="emphasis">.com, .exe</em>, <em class="emphasis">.bat</em>, and<em class="emphasis">.cmd</em>. If you inadvertently lose thoseextensions, you'll have difficulty invokingapplications and script files.</p></dd><dt><i>PERL5LIB</i></dt><dd>A colon-separated list of directories in <a name="INDEX-166" />which to look for Perl library filesbefore looking in the standard library and the current directory. IfPERL5LIB is not defined, PERLLIB is used. When running taint checks,neither variable is used. The script should instead say:</p><blockquote><pre class="code">use lib "/my/directory";</pre></blockquote></dd><dt><i>PERL5OPT</i></dt><dd>Command-line options (switches). Switches<a name="INDEX-167" />in thisvariable are taken as if they were on every Perl command line. Onlythe <em class="emphasis">-</em>[<em class="emphasis">DIMUdmw</em>] switches areallowed. When running taint checks, this variable is ignored.</p></dd><dt><i>PERLLIB</i></dt><dd>A colon-separated list of directories in <a name="INDEX-168" />which to look for Perl library filesbefore looking in the standard library and the current directory. IfPERL5LIB is defined, PERLLIB is not used.</p></dd><dt><i>PERL5DB</i></dt><dd>The command used to load the debugger code. The default is:</p><blockquote><pre class="code">BEGIN { require 'perl5db.pl' }</pre></blockquote></dd><dt><i>PERL5SHELL</i></dt><dd>On Win32 systems, may be set to an alternative shell for Perl<a name="INDEX-169" />to useinternally to execute "backtick"commands or the <tt class="literal">system</tt> function.</p></dd><dt><i>PERL_DEBUG_MSTATS</i></dt><dd><a name="INDEX-170" />Relevant only if your Perl executablewas built with -DDEBUGGING_MSTATS. If set, causes memory statisticsto be dumped after execution. If set to an integer greater than 1, italso causes memory statistics to be dumped after compilation.</p></dd><dt><i>PERL_DESTRUCT_LEVEL</i></dt><dd><a name="INDEX-171" />Relevant only if your Perl executablewas built with -DDEBUGGING. Controls the behavior of globaldestruction of objects and other references.</p></dd></dl><p>Perl also has environment variables that control how Perl handlesdata specific to particular natural languages. See the<em class="emphasis">perllocale</em> manpage<a name="INDEX-172" />. </p><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch03_02.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch03_04.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">3.2. Command-Line Options</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">3.4. The Perl Compiler</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2002</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -