vars.html
来自「perl教程」· HTML 代码 · 共 70 行
HTML
70 行
<?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>vars - Perl pragma to predeclare global variable names</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>vars - Perl pragma to predeclare global variable names</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>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>vars - Perl pragma to predeclare global variable names (obsolete)</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
<span class="keyword">use</span> <span class="variable">vars</span> <span class="string">qw($frob @mung %seen)</span><span class="operator">;</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>NOTE: For variables in the current package, the functionality provided
by this pragma has been superseded by <a href="../lib/Pod/perlfunc.html#item_our"><code>our</code></a> declarations, available
in Perl v5.6.0 or later. See <a href="../lib/Pod/perlfunc.html#our">our in the perlfunc manpage</a>.</p>
<p>This will predeclare all the variables whose names are
in the list, allowing you to use them under "use strict", and
disabling any typo warnings.</p>
<p>Unlike pragmas that affect the <a href="../lib/Pod/perlvar.html#item___h"><code>$^H</code></a> hints variable, the <code>use vars</code> and
<code>use subs</code> declarations are not BLOCK-scoped. They are thus effective
for the entire file in which they appear. You may not rescind such
declarations with <code>no vars</code> or <code>no subs</code>.</p>
<p>Packages such as the <strong>AutoLoader</strong> and <strong>SelfLoader</strong> that delay
loading of subroutines within packages can create problems with
package lexicals defined using <a href="../lib/Pod/perlfunc.html#item_my"><code>my()</code></a>. While the <strong>vars</strong> pragma
cannot duplicate the effect of package lexicals (total transparency
outside of the package), it can act as an acceptable substitute by
pre-declaring global symbols, ensuring their availability to the
later-loaded routines.</p>
<p>See <a href="../lib/Pod/perlmodlib.html#pragmatic_modules">Pragmatic Modules in the perlmodlib manpage</a>.</p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?