filetest.html

来自「perl教程」· HTML 代码 · 共 88 行

HTML
88
字号
<?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>filetest - Perl pragma to control the filetest permission operators</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>filetest - Perl pragma to control the filetest permission operators</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>

		<li><a href="#subpragma_access">subpragma access</a></li>
	</ul>

</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>filetest - Perl pragma to control the filetest permission operators</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
    <span class="variable">$can_perhaps_read</span> <span class="operator">=</span> <span class="keyword">-r</span> <span class="string">"file"</span><span class="operator">;</span>      <span class="comment"># use the mode bits</span>
    <span class="operator">{</span>
        <span class="keyword">use</span> <span class="variable">filetest</span> <span class="string">'access'</span><span class="operator">;</span>          <span class="comment"># intuit harder</span>
        <span class="variable">$can_really_read</span> <span class="operator">=</span> <span class="keyword">-r</span> <span class="string">"file"</span><span class="operator">;</span>
    <span class="operator">}</span>
    <span class="variable">$can_perhaps_read</span> <span class="operator">=</span> <span class="keyword">-r</span> <span class="string">"file"</span><span class="operator">;</span>      <span class="comment"># use the mode bits again</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This pragma tells the compiler to change the behaviour of the filetest
permission operators, <code>-r</code> <a href="../lib/Pod/perlrun.html#item__2dw"><code>-w</code></a> <a href="../lib/Pod/perlrun.html#item__2dx"><code>-x</code></a> <code>-R</code> <a href="../lib/Pod/perlrun.html#item__2dw"><code>-W</code></a> <a href="../lib/Pod/perlrun.html#item__2dx"><code>-X</code></a>
(see <a href="../lib/Pod/perlfunc.html">the perlfunc manpage</a>).</p>
<p>The default behaviour is to use the mode bits as returned by the <a href="../lib/Pod/perlfunc.html#item_stat"><code>stat()</code></a>
family of calls.  This, however, may not be the right thing to do if
for example various ACL (access control lists) schemes are in use.
For such environments, <code>use filetest</code> may help the permission
operators to return results more consistent with other tools.</p>
<p>Each &quot;use filetest&quot; or &quot;no filetest&quot; affects statements to the end of
the enclosing block.</p>
<p>There may be a slight performance decrease in the filetests
when <code>use filetest</code> is in effect, because in some systems
the extended functionality needs to be emulated.</p>
<p><strong>NOTE</strong>: using the file tests for security purposes is a lost cause
from the start: there is a window open for race conditions (who is to
say that the permissions will not change between the test and the real
operation?).  Therefore if you are serious about security, just try
the real operation and test for its success - think in terms of atomic
operations.</p>
<p>
</p>
<h2><a name="subpragma_access">subpragma access</a></h2>
<p>Currently only one subpragma, <code>access</code> is implemented.  It enables
(or disables) the use of <code>access()</code> or similar system calls.  This
extended filetest functionality is used only when the argument of the
operators is a filename, not when it is a filehandle.</p>

</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?