zlib.html
来自「perl教程」· HTML 代码 · 共 401 行 · 第 1/2 页
HTML
401 行
</dd>
</li>
<dt><strong><a name="item_setpos">setpos ( POS )</a></strong>
<dd>
<p>Set the current position, using the opaque value returned by <a href="#item_getpos"><code>getpos()</code></a>.
Not yet supported.</p>
</dd>
</li>
<dt><strong><a name="item_getpos">getpos ( POS )</a></strong>
<dd>
<p>Return the current position in the string, as an opaque object.
Not yet supported.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="using_the_external_gzip">USING THE EXTERNAL GZIP</a></h1>
<p>If the external <em>gzip</em> is used, the following <a href="#item_open"><code>open</code></a>s are used:</p>
<pre>
open(FH, "gzip -dc $filename |") # for read opens
open(FH, " | gzip > $filename") # for write opens</pre>
<p>You can modify the 'commands' for example to hardwire
an absolute path by e.g.</p>
<pre>
<span class="keyword">use</span> <span class="variable">IO::Zlib</span> <span class="string">':gzip_read_open'</span> <span class="operator">=></span> <span class="string">'/some/where/gunzip -c %s |'</span><span class="operator">;</span>
<span class="keyword">use</span> <span class="variable">IO::Zlib</span> <span class="string">':gzip_write_open'</span> <span class="operator">=></span> <span class="string">'| /some/where/gzip.exe > %s'</span><span class="operator">;</span>
</pre>
<p>The <code>%s</code> is expanded to be the filename (<a href="../../lib/Pod/perlfunc.html#item_sprintf"><code>sprintf</code></a> is used, so be
careful to escape any other <code>%</code> signs). The 'commands' are checked
for sanity - they must contain the <code>%s</code>, and the read open must end
with the pipe sign, and the write open must begin with the pipe sign.</p>
<p>
</p>
<hr />
<h1><a name="class_methods">CLASS METHODS</a></h1>
<dl>
<dt><strong><a name="item_has_compress_zlib">has_Compress_Zlib</a></strong>
<dd>
<p>Returns true if <code>Compress::Zlib</code> is available. Note that this does
not mean that <code>Compress::Zlib</code> is being used: see <a href="#item_gzip_external">gzip_external</a>
and <a href="#item_gzip_used">gzip_used</a>.</p>
</dd>
</li>
<dt><strong><a name="item_gzip_external">gzip_external</a></strong>
<dd>
<p>Undef if an external <em>gzip</em> <strong>can</strong> be used if <code>Compress::Zlib</code> is
not available (see <a href="#item_has_compress_zlib">has_Compress_Zlib</a>), true if an external <em>gzip</em>
is explicitly used, false if an external <em>gzip</em> must not be used.
See <a href="#item_gzip_used">gzip_used</a>.</p>
</dd>
</li>
<dt><strong><a name="item_gzip_used">gzip_used</a></strong>
<dd>
<p>True if an external <em>gzip</em> is being used, false if not.</p>
</dd>
</li>
<dt><strong><a name="item_gzip_read_open">gzip_read_open</a></strong>
<dd>
<p>Return the 'command' being used for opening a file for reading using an
external <em>gzip</em>.</p>
</dd>
</li>
<dt><strong><a name="item_gzip_write_open">gzip_write_open</a></strong>
<dd>
<p>Return the 'command' being used for opening a file for writing using an
external <em>gzip</em>.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="diagnostics">DIAGNOSTICS</a></h1>
<dl>
<dt><strong><a name="item_io_3a_3azlib_3a_3agetlines_3a_must_be_called_in_li">IO::Zlib::getlines: must be called in list context</a></strong>
<dd>
<p>If you want read lines, you must read in list context.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3agzopen_external_3a_mode__27_2e_2">IO::Zlib::gzopen_external: mode '...' is illegal</a></strong>
<dd>
<p>Use only modes 'rb' or 'wb' or /wb[1-9]/.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3aimport_3a__27_2e_2e_2e_27_is_ill">IO::Zlib::import: '...' is illegal</a></strong>
<dd>
<p>The known import symbols are the <code>:gzip_external</code>, <code>:gzip_read_open</code>,
and <code>:gzip_write_open</code>. Anything else is not recognized.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3aimport_3a__27_3agzip_external_27">IO::Zlib::import: ':gzip_external' requires an argument</a></strong>
<dd>
<p>The <code>:gzip_external</code> requires one boolean argument.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3aimport_3a__27gzip_read_open_27_r">IO::Zlib::import: 'gzip_read_open' requires an argument</a></strong>
<dd>
<p>The <code>:gzip_external</code> requires one string argument.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3aimport_3a__27gzip_read_27__27_2e">IO::Zlib::import: 'gzip_read' '...' is illegal</a></strong>
<dd>
<p>The <code>:gzip_read_open</code> argument must end with the pipe sign (|)
and have the <code>%s</code> for the filename. See <a href="#using_the_external_gzip">USING THE EXTERNAL GZIP</a>.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3aimport_3a__27gzip_write_open_27_">IO::Zlib::import: 'gzip_write_open' requires an argument</a></strong>
<dd>
<p>The <code>:gzip_external</code> requires one string argument.</p>
</dd>
</li>
<dt><strong>IO::Zlib::import: 'gzip_write_open' '...' is illegal</strong>
<dd>
<p>The <code>:gzip_write_open</code> argument must begin with the pipe sign (|)
and have the <code>%s</code> for the filename. An output redirect (>) is also
often a good idea, depending on your operating system shell syntax.
See <a href="#using_the_external_gzip">USING THE EXTERNAL GZIP</a>.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3aimport_3a_no_compress_3a_3azlib_">IO::Zlib::import: no Compress::Zlib and no external gzip</a></strong>
<dd>
<p>Given that we failed to load <code>Compress::Zlib</code> and that the use of
an external <em>gzip</em> was disabled, IO::Zlib has not much chance of working.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3aopen_3a_needs_a_filename">IO::Zlib::open: needs a filename</a></strong>
<dd>
<p>No filename, no open.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3aread_3a_nbytes_must_be_specified">IO::Zlib::READ: NBYTES must be specified</a></strong>
<dd>
<p>We must know how much to read.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3aread_3a_offset_is_not_supported">IO::Zlib::READ: OFFSET is not supported</a></strong>
<dd>
<p>Offsets of gzipped streams are not supported.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3awrite_3a_too_long_length">IO::Zlib::WRITE: too long LENGTH</a></strong>
<dd>
<p>The LENGTH must be less than or equal to the buffer size.</p>
</dd>
</li>
<dt><strong><a name="item_io_3a_3azlib_3a_3awrite_3a_offset_is_not_supported">IO::Zlib::WRITE: OFFSET is not supported</a></strong>
<dd>
<p>Offsets of gzipped streams are not supported.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/Pod/perlfunc.html">the perlfunc manpage</a>,
<a href="../../lib/Pod/perlop.html#i_o_operators">I/O Operators in the perlop manpage</a>,
<a href="../../lib/IO/Handle.html">the IO::Handle manpage</a>,
<a href="../../lib/Compress/Zlib.html">the Compress::Zlib manpage</a></p>
<p>
</p>
<hr />
<h1><a name="history">HISTORY</a></h1>
<p>Created by Tom Hughes <<em><a href="mailto:tom@compton.nu">tom@compton.nu</a></em>>.</p>
<p>Support for external gzip added by Jarkko Hietaniemi <<em><a href="mailto:jhi@iki.fi">jhi@iki.fi</a></em>>.</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright (c) 1998-2004 Tom Hughes <<em><a href="mailto:tom@compton.nu">tom@compton.nu</a></em>>.
All rights reserved. This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.</p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?