📄 config.html
字号:
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../displayToc.js"></script>
<script language="JavaScript" src="../tocParas.js"></script>
<script language="JavaScript" src="../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../scineplex.css">
<title>Config - access Perl configuration information</title>
<link rel="stylesheet" href="../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>
<body>
<script>writelinks('__top__',1);</script>
<h1><a>Config - access Perl configuration information</a></h1>
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#example">EXAMPLE</a></li>
<li><a href="#warning">WARNING</a></li>
<li><a href="#glossary">GLOSSARY</a></li>
<ul>
<li><a href="#_">_</a></li>
<li><a href="#a">a</a></li>
<li><a href="#b">b</a></li>
<li><a href="#c">c</a></li>
<li><a href="#d">d</a></li>
<li><a href="#e">e</a></li>
<li><a href="#f">f</a></li>
<li><a href="#g">g</a></li>
<li><a href="#h">h</a></li>
<li><a href="#i">i</a></li>
<li><a href="#k">k</a></li>
<li><a href="#l">l</a></li>
<li><a href="#m">m</a></li>
<li><a href="#m">M</a></li>
<li><a href="#n">n</a></li>
<li><a href="#o">o</a></li>
<li><a href="#p">p</a></li>
<li><a href="#p">P</a></li>
<li><a href="#q">q</a></li>
<li><a href="#r">r</a></li>
<li><a href="#s">s</a></li>
<li><a href="#t">t</a></li>
<li><a href="#u">u</a></li>
<li><a href="#v">v</a></li>
<li><a href="#x">x</a></li>
<li><a href="#y">y</a></li>
<li><a href="#z">z</a></li>
</ul>
<li><a href="#note">NOTE</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Config - access Perl configuration information</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
<span class="keyword">use</span> <span class="variable">Config</span><span class="operator">;</span>
<span class="keyword">if</span> <span class="operator">(</span><span class="variable">$Config</span><span class="operator">{</span><span class="string">usethreads</span><span class="operator">}</span><span class="operator">)</span> <span class="operator">{</span>
<span class="keyword">print</span> <span class="string">"has thread support\n"</span>
<span class="operator">}</span>
</pre>
<pre>
<span class="keyword">use</span> <span class="variable">Config</span> <span class="string">qw(myconfig config_sh config_vars config_re)</span><span class="operator">;</span>
</pre>
<pre>
<span class="keyword">print</span> <span class="variable">myconfig</span><span class="operator">();</span>
</pre>
<pre>
<span class="keyword">print</span> <span class="variable">config_sh</span><span class="operator">();</span>
</pre>
<pre>
<span class="keyword">print</span> <span class="variable">config_re</span><span class="operator">();</span>
</pre>
<pre>
<span class="variable">config_vars</span><span class="operator">(</span><span class="string">qw(osname archname)</span><span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>The Config module contains all the information that was available to
the <code>Configure</code> program at Perl build time (over 900 values).</p>
<p>Shell variables from the <em>config.sh</em> file (written by Configure) are
stored in the readonly-variable <code>%Config</code>, indexed by their names.</p>
<p>Values stored in config.sh as 'undef' are returned as undefined
values. The perl <a href="../lib/Pod/perlfunc.html#item_exists"><code>exists</code></a> function can be used to check if a
named variable exists.</p>
<dl>
<dt><strong><a name="item_myconfig"><code>myconfig()</code></a></strong>
<dd>
<p>Returns a textual summary of the major perl configuration values.
See also <a href="../lib/Pod/perlrun.html#item__2dv"><code>-V</code></a> in <a href="../lib/Pod/perlrun.html#switches">Switches in the perlrun manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_config_sh"><code>config_sh()</code></a></strong>
<dd>
<p>Returns the entire perl configuration information in the form of the
original config.sh shell variable assignment script.</p>
</dd>
</li>
<dt><strong><a name="item_config_re"><code>config_re($regex)</code></a></strong>
<dd>
<p>Like <a href="#item_config_sh"><code>config_sh()</code></a> but returns, as a list, only the config entries who's
names match the $regex.</p>
</dd>
</li>
<dt><strong><a name="item_config_vars"><code>config_vars(@names)</code></a></strong>
<dd>
<p>Prints to STDOUT the values of the named configuration variable. Each is
printed on a separate line in the form:</p>
</dd>
<dd>
<pre>
<span class="variable">name</span><span class="operator">=</span><span class="string">'value'</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<p>Names which are unknown are output as <code>name='UNKNOWN';</code>.
See also <code>-V:name</code> in <a href="../lib/Pod/perlrun.html#switches">Switches in the perlrun manpage</a>.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="example">EXAMPLE</a></h1>
<p>Here's a more sophisticated example of using %Config:</p>
<pre>
<span class="keyword">use</span> <span class="variable">Config</span><span class="operator">;</span>
<span class="keyword">use</span> <span class="variable">strict</span><span class="operator">;</span>
</pre>
<pre>
<span class="keyword">my</span> <span class="variable">%sig_num</span><span class="operator">;</span>
<span class="keyword">my</span> <span class="variable">@sig_name</span><span class="operator">;</span>
<span class="keyword">unless</span><span class="operator">(</span><span class="variable">$Config</span><span class="operator">{</span><span class="string">sig_name</span><span class="operator">}</span> <span class="operator">&&</span> <span class="variable">$Config</span><span class="operator">{</span><span class="string">sig_num</span><span class="operator">}</span><span class="operator">)</span> <span class="operator">{</span>
<span class="keyword">die</span> <span class="string">"No sigs?"</span><span class="operator">;</span>
<span class="operator">}</span> <span class="keyword">else</span> <span class="operator">{</span>
<span class="keyword">my</span> <span class="variable">@names</span> <span class="operator">=</span> <span class="keyword">split</span> <span class="string">' '</span><span class="operator">,</span> <span class="variable">$Config</span><span class="operator">{</span><span class="string">sig_name</span><span class="operator">}</span><span class="operator">;</span>
<span class="variable">@sig_num</span><span class="operator">{</span><span class="variable">@names</span><span class="operator">}</span> <span class="operator">=</span> <span class="keyword">split</span> <span class="string">' '</span><span class="operator">,</span> <span class="variable">$Config</span><span class="operator">{</span><span class="string">sig_num</span><span class="operator">}</span><span class="operator">;</span>
<span class="keyword">foreach</span> <span class="operator">(</span><span class="variable">@names</span><span class="operator">)</span> <span class="operator">{</span>
<span class="variable">$sig_name</span><span class="operator">[</span><span class="variable">$sig_num</span><span class="operator">{</span><span class="variable">$_</span><span class="operator">}]</span> <span class="operator">||=</span> <span class="variable">$_</span><span class="operator">;</span>
<span class="operator">}</span>
<span class="operator">}</span>
</pre>
<pre>
<span class="keyword">print</span> <span class="string">"signal #17 = $sig_name[17]\n"</span><span class="operator">;</span>
<span class="keyword">if</span> <span class="operator">(</span><span class="variable">$sig_num</span><span class="operator">{</span><span class="string">ALRM</span><span class="operator">}</span><span class="operator">)</span> <span class="operator">{</span>
<span class="keyword">print</span> <span class="string">"SIGALRM is $sig_num{ALRM}\n"</span><span class="operator">;</span>
<span class="operator">}</span>
</pre>
<p>
</p>
<hr />
<h1><a name="warning">WARNING</a></h1>
<p>Because this information is not stored within the perl executable
itself it is possible (but unlikely) that the information does not
relate to the actual perl binary which is being used to access it.</p>
<p>The Config module is installed into the architecture and version
specific library directory ($Config{installarchlib}) and it checks the
perl version number when loaded.</p>
<p>The values stored in config.sh may be either single-quoted or
double-quoted. Double-quoted strings are handy for those cases where you
need to include escape sequences in the strings. To avoid runtime variable
interpolation, any <code>$</code> and <code>@</code> characters are replaced by <code>\$</code> and
<code>\@</code>, respectively. This isn't foolproof, of course, so don't embed <code>\$</code>
or <code>\@</code> in double-quoted strings unless you're willing to deal with the
consequences. (The slashes will end up escaped and the <code>$</code> or <code>@</code> will
trigger variable interpolation)</p>
<p>
</p>
<hr />
<h1><a name="glossary">GLOSSARY</a></h1>
<p>Most <code>Config</code> variables are determined by the <code>Configure</code> script
on platforms supported by it (which is most UNIX platforms). Some
platforms have custom-made <code>Config</code> variables, and may thus not have
some of the variables described below, or may have extraneous variables
specific to that particular port. See the port specific documentation
in such cases.</p>
<p>
</p>
<h2><a name="_">_</a></h2>
<dl>
<dt><strong><a name="item__a"><code>_a</code></a></strong>
<dd>
<p>From <em>Unix.U</em>:</p>
</dd>
<dd>
<p>This variable defines the extension used for ordinary library files.
For unix, it is <em>.a</em>. The <em>.</em> is included. Other possible
values include <em>.lib</em>.</p>
</dd>
</li>
<dt><strong><a name="item__exe"><code>_exe</code></a></strong>
<dd>
<p>From <em>Unix.U</em>:</p>
</dd>
<dd>
<p>This variable defines the extension used for executable files.
<code>DJGPP</code>, Cygwin and <em>OS/2</em> use <em>.exe</em>. Stratus <code>VOS</code> uses <em>.pm</em>.
On operating systems which do not require a specific extension
for executable files, this variable is empty.</p>
</dd>
</li>
<dt><strong><a name="item__o"><code>_o</code></a></strong>
<dd>
<p>From <em>Unix.U</em>:</p>
</dd>
<dd>
<p>This variable defines the extension used for object files.
For unix, it is <em>.o</em>. The <em>.</em> is included. Other possible
values include <em>.obj</em>.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="a">a</a></h2>
<dl>
<dt><strong><a name="item_afs"><code>afs</code></a></strong>
<dd>
<p>From <em>afs.U</em>:</p>
</dd>
<dd>
<p>This variable is set to <code>true</code> if <code>AFS</code> (Andrew File System) is used
on the system, <code>false</code> otherwise. It is possible to override this
with a hint value or command line option, but you'd better know
what you are doing.</p>
</dd>
</li>
<dt><strong><a name="item_afsroot"><code>afsroot</code></a></strong>
<dd>
<p>From <em>afs.U</em>:</p>
</dd>
<dd>
<p>This variable is by default set to <em>/afs</em>. In the unlikely case
this is not the correct root, it is possible to override this with
a hint value or command line option. This will be used in subsequent
tests for AFSness in the Perl configure and test process.</p>
</dd>
</li>
<dt><strong><a name="item_alignbytes"><code>alignbytes</code></a></strong>
<dd>
<p>From <em>alignbytes.U</em>:</p>
</dd>
<dd>
<p>This variable holds the number of bytes required to align a
double-- or a long double when applicable. Usual values are
2, 4 and 8. The default is eight, for safety.</p>
</dd>
</li>
<dt><strong><a name="item_ansi2knr"><code>ansi2knr</code></a></strong>
<dd>
<p>From <em>ansi2knr.U</em>:</p>
</dd>
<dd>
<p>This variable is set if the user needs to run ansi2knr.
Currently, this is not supported, so we just abort.</p>
</dd>
</li>
<dt><strong><a name="item_aphostname"><code>aphostname</code></a></strong>
<dd>
<p>From <em>d_gethname.U</em>:</p>
</dd>
<dd>
<p>This variable contains the command which can be used to compute the
host name. The command is fully qualified by its absolute path, to make
it safe when used by a process with super-user privileges.</p>
</dd>
</li>
<dt><strong><a name="item_api_revision"><code>api_revision</code></a></strong>
<dd>
<p>From <em>patchlevel.U</em>:</p>
</dd>
<dd>
<p>The three variables, api_revision, api_version, and
api_subversion, specify the version of the oldest perl binary
compatible with the present perl. In a full version string
such as <em>5.6.1</em>, api_revision is the <code>5</code>.
Prior to 5.5.640, the format was a floating point number,
like 5.00563.</p>
</dd>
<dd>
<p><em>perl.c</em>:incpush() and <em>lib/lib.pm</em> will automatically search in
<em>$sitelib/.</em>. for older directories back to the limit specified
by these api_ variables. This is only useful if you have a
perl library directory tree structured like the default one.
See <code>INSTALL</code> for how this works. The versioned site_perl
directory was introduced in 5.005, so that is the lowest
possible value. The version list appropriate for the current
system is determined in <em>inc_version_list.U</em>.</p>
</dd>
<dd>
<p><code>XXX</code> To do: Since compatibility can depend on compile time
options (such as bincompat, longlong, etc.) it should
(perhaps) be set by Configure, but currently it isn't.
Currently, we read a hard-wired value from <em>patchlevel.h</em>.
Perhaps what we ought to do is take the hard-wired value from
<em>patchlevel.h</em> but then modify it if the current Configure
options warrant. <em>patchlevel.h</em> then would use an #ifdef guard.</p>
</dd>
</li>
<dt><strong><a name="item_api_subversion"><code>api_subversion</code></a></strong>
<dd>
<p>From <em>patchlevel.U</em>:</p>
</dd>
<dd>
<p>The three variables, api_revision, api_version, and
api_subversion, specify the version of the oldest perl binary
compatible with the present perl. In a full version string
such as <em>5.6.1</em>, api_subversion is the <code>1</code>. See api_revision for
full details.</p>
</dd>
</li>
<dt><strong><a name="item_api_version"><code>api_version</code></a></strong>
<dd>
<p>From <em>patchlevel.U</em>:</p>
</dd>
<dd>
<p>The three variables, api_revision, api_version, and
api_subversion, specify the version of the oldest perl binary
compatible with the present perl. In a full version string
such as <em>5.6.1</em>, api_version is the <code>6</code>. See api_revision for
full details. As a special case, 5.5.0 is rendered in the
old-style as 5.005. (In the 5.005_0x maintenance series,
this was the only versioned directory in $sitelib.)</p>
</dd>
</li>
<dt><strong><a name="item_api_versionstring"><code>api_versionstring</code></a></strong>
<dd>
<p>From <em>patchlevel.U</em>:</p>
</dd>
<dd>
<p>This variable combines api_revision, api_version, and
api_subversion in a format such as 5.6.1 (or 5_6_1) suitable
for use as a directory name. This is filesystem dependent.</p>
</dd>
</li>
<dt><strong><a name="item_ar"><code>ar</code></a></strong>
<dd>
<p>From <em>Loc.U</em>:</p>
</dd>
<dd>
<p>This variable is used internally by Configure to determine the
full pathname (if any) of the ar program. After Configure runs,
the value is reset to a plain <a href="#item_ar"><code>ar</code></a> and is not useful.</p>
</dd>
</li>
<dt><strong><a name="item_archlib"><code>archlib</code></a></strong>
<dd>
<p>From <em>archlib.U</em>:</p>
</dd>
<dd>
<p>This variable holds the name of the directory in which the user wants
to put architecture-dependent public library files for $package.
It is most often a local directory such as <em>/usr/local/lib</em>.
Programs using this variable must be prepared to deal
with filename expansion.</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -