handle.html
来自「perl教程」· HTML 代码 · 共 185 行
HTML
185 行
<?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>Tie::StdHandle - base class definitions for tied handles</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__',2);</script>
<h1><a>Tie::StdHandle - base class definitions for tied handles</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="#more_information">MORE INFORMATION</a></li>
<li><a href="#compatibility">COMPATIBILITY</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Tie::Handle, Tie::StdHandle - base class definitions for tied handles</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
<span class="keyword">package</span> <span class="variable">NewHandle</span><span class="operator">;</span>
<span class="keyword">require</span> <span class="variable">Tie::Handle</span><span class="operator">;</span>
</pre>
<pre>
<span class="variable">@ISA</span> <span class="operator">=</span> <span class="string">qw(Tie::Handle)</span><span class="operator">;</span>
</pre>
<pre>
<span class="keyword">sub</span><span class="variable"> READ </span><span class="operator">{</span> <span class="operator">...</span> <span class="operator">}</span> <span class="comment"># Provide a needed method</span>
<span class="keyword">sub</span><span class="variable"> TIEHANDLE </span><span class="operator">{</span> <span class="operator">...</span> <span class="operator">}</span> <span class="comment"># Overrides inherited method</span>
</pre>
<pre>
<span class="keyword">package</span> <span class="variable">main</span><span class="operator">;</span>
</pre>
<pre>
<span class="keyword">tie</span> <span class="variable">*FH</span><span class="operator">,</span> <span class="string">'NewHandle'</span><span class="operator">;</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This module provides some skeletal methods for handle-tying classes. See
<a href="../../lib/Pod/perltie.html">the perltie manpage</a> for a list of the functions required in tying a handle to a package.
The basic <strong>Tie::Handle</strong> package provides a <code>new</code> method, as well as methods
<code>TIEHANDLE</code>, <code>PRINT</code>, <code>PRINTF</code> and <code>GETC</code>.</p>
<p>For developers wishing to write their own tied-handle classes, the methods
are summarized below. The <a href="../../lib/Pod/perltie.html">the perltie manpage</a> section not only documents these, but
has sample code as well:</p>
<dl>
<dt><strong><a name="item_tiehandle_classname_2c_list">TIEHANDLE classname, LIST</a></strong>
<dd>
<p>The method invoked by the command <code>tie *glob, classname</code>. Associates a new
glob instance with the specified class. <code>LIST</code> would represent additional
arguments (along the lines of <a href="../../lib/AnyDBM_File.html">the AnyDBM_File manpage</a> and compatriots) needed to
complete the association.</p>
</dd>
</li>
<dt><strong><a name="item_write_this_2c_scalar_2c_length_2c_offset">WRITE this, scalar, length, offset</a></strong>
<dd>
<p>Write <em>length</em> bytes of data from <em>scalar</em> starting at <em>offset</em>.</p>
</dd>
</li>
<dt><strong><a name="item_print_this_2c_list">PRINT this, LIST</a></strong>
<dd>
<p>Print the values in <em>LIST</em></p>
</dd>
</li>
<dt><strong><a name="item_printf_this_2c_format_2c_list">PRINTF this, format, LIST</a></strong>
<dd>
<p>Print the values in <em>LIST</em> using <em>format</em></p>
</dd>
</li>
<dt><strong><a name="item_read_this_2c_scalar_2c_length_2c_offset">READ this, scalar, length, offset</a></strong>
<dd>
<p>Read <em>length</em> bytes of data into <em>scalar</em> starting at <em>offset</em>.</p>
</dd>
</li>
<dt><strong><a name="item_readline_this">READLINE this</a></strong>
<dd>
<p>Read a single line</p>
</dd>
</li>
<dt><strong><a name="item_getc_this">GETC this</a></strong>
<dd>
<p>Get a single character</p>
</dd>
</li>
<dt><strong><a name="item_close_this">CLOSE this</a></strong>
<dd>
<p>Close the handle</p>
</dd>
</li>
<dt><strong><a name="item_open_this_2c_filename">OPEN this, filename</a></strong>
<dd>
<p>(Re-)open the handle</p>
</dd>
</li>
<dt><strong><a name="item_binmode_this">BINMODE this</a></strong>
<dd>
<p>Specify content is binary</p>
</dd>
</li>
<dt><strong><a name="item_eof_this">EOF this</a></strong>
<dd>
<p>Test for end of file.</p>
</dd>
</li>
<dt><strong><a name="item_tell_this">TELL this</a></strong>
<dd>
<p>Return position in the file.</p>
</dd>
</li>
<dt><strong><a name="item_seek_this_2c_offset_2c_whence">SEEK this, offset, whence</a></strong>
<dd>
<p>Position the file.</p>
</dd>
<dd>
<p>Test for end of file.</p>
</dd>
</li>
<dt><strong><a name="item_destroy_this">DESTROY this</a></strong>
<dd>
<p>Free the storage associated with the tied handle referenced by <em>this</em>.
This is rarely needed, as Perl manages its memory quite well. But the
option exists, should a class wish to perform specific actions upon the
destruction of an instance.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="more_information">MORE INFORMATION</a></h1>
<p>The <a href="../../lib/Pod/perltie.html">the perltie manpage</a> section contains an example of tying handles.</p>
<p>
</p>
<hr />
<h1><a name="compatibility">COMPATIBILITY</a></h1>
<p>This version of Tie::Handle is neither related to nor compatible with
the Tie::Handle (3.0) module available on CPAN. It was due to an
accident that two modules with the same name appeared. The namespace
clash has been cleared in favor of this module that comes with the
perl core in September 2000 and accordingly the version number has
been bumped up to 4.0.</p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?