Edit D:\app\Administrator\product\11.2.0\dbhome_1\perl\html\lib\IO\Zlib.html
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>IO::Zlib - IO:: style interface to L<Compress::Zlib></title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:" /> </head> <body style="background-color: white"> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> IO::Zlib - IO:: style interface to L<Compress::Zlib></span></strong></big> </td></tr> </table> <!-- INDEX BEGIN --> <div name="index"> <p><a name="__index__"></a></p> <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="#constructor">CONSTRUCTOR</a></li> <li><a href="#object_methods">OBJECT METHODS</a></li> <li><a href="#using_the_external_gzip">USING THE EXTERNAL GZIP</a></li> <li><a href="#class_methods">CLASS METHODS</a></li> <li><a href="#diagnostics">DIAGNOSTICS</a></li> <li><a href="#see_also">SEE ALSO</a></li> <li><a href="#history">HISTORY</a></li> <li><a href="#copyright">COPYRIGHT</a></li> </ul> <hr name="index" /> </div> <!-- INDEX END --> <p> </p> <h1><a name="name">NAME</a></h1> <p>IO::Zlib - IO:: style interface to <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/Compress/Zlib.html">the Compress::Zlib manpage</a></p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <p>With any version of Perl 5 you can use the basic OO interface:</p> <pre> use IO::Zlib;</pre> <pre> $fh = new IO::Zlib; if ($fh->open("file.gz", "rb")) { print <$fh>; $fh->close; }</pre> <pre> $fh = IO::Zlib->new("file.gz", "wb9"); if (defined $fh) { print $fh "bar\n"; $fh->close; }</pre> <pre> $fh = IO::Zlib->new("file.gz", "rb"); if (defined $fh) { print <$fh>; undef $fh; # automatically closes the file }</pre> <p>With Perl 5.004 you can also use the TIEHANDLE interface to access compressed files just like ordinary files:</p> <pre> use IO::Zlib;</pre> <pre> tie *FILE, 'IO::Zlib', "file.gz", "wb"; print FILE "line 1\nline2\n";</pre> <pre> tie *FILE, 'IO::Zlib', "file.gz", "rb"; while (<FILE>) { print "LINE: ", $_ };</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p><code>IO::Zlib</code> provides an IO:: style interface to <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/Compress/Zlib.html">the Compress::Zlib manpage</a> and hence to gzip/zlib compressed files. It provides many of the same methods as the <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Handle.html">the IO::Handle manpage</a> interface.</p> <p>Starting from IO::Zlib version 1.02, IO::Zlib can also use an external <em class="file">gzip</em> command. The default behaviour is to try to use an external <em class="file">gzip</em> if no <code>Compress::Zlib</code> can be loaded, unless explicitly disabled by</p> <pre> use IO::Zlib qw(:gzip_external 0);</pre> <p>If explicitly enabled by</p> <pre> use IO::Zlib qw(:gzip_external 1);</pre> <p>then the external <em class="file">gzip</em> is used <strong>instead</strong> of <code>Compress::Zlib</code>.</p> <p> </p> <hr /> <h1><a name="constructor">CONSTRUCTOR</a></h1> <dl> <dt><strong><a name="new" class="item">new ( [ARGS] )</a></strong> <dd> <p>Creates an <code>IO::Zlib</code> object. If it receives any parameters, they are passed to the method <a href="#open"><code>open</code></a>; if the open fails, the object is destroyed. Otherwise, it is returned to the caller.</p> </dd> </li> </dl> <p> </p> <hr /> <h1><a name="object_methods">OBJECT METHODS</a></h1> <dl> <dt><strong><a name="open" class="item">open ( FILENAME, MODE )</a></strong> <dd> <p><a href="#open"><code>open</code></a> takes two arguments. The first is the name of the file to open and the second is the open mode. The mode can be anything acceptable to <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/Compress/Zlib.html">the Compress::Zlib manpage</a> and by extension anything acceptable to <em>zlib</em> (that basically means POSIX <code>fopen()</code> style mode strings plus an optional number to indicate the compression level).</p> </dd> </li> <dt><strong><a name="opened" class="item">opened</a></strong> <dd> <p>Returns true if the object currently refers to a opened file.</p> </dd> </li> <dt><strong><a name="close" class="item">close</a></strong> <dd> <p>Close the file associated with the object and disassociate the file from the handle. Done automatically on destroy.</p> </dd> </li> <dt><strong><a name="getc" class="item">getc</a></strong> <dd> <p>Return the next character from the file, or undef if none remain.</p> </dd> </li> <dt><strong><a name="getline" class="item">getline</a></strong> <dd> <p>Return the next line from the file, or undef on end of string. Can safely be called in an array context. Currently ignores $/ ($INPUT_RECORD_SEPARATOR or $RS when <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/English.html">the English manpage</a> is in use) and treats lines as delimited by "\n".</p> </dd> </li> <dt><strong><a name="getlines" class="item">getlines</a></strong> <dd> <p>Get all remaining lines from the file. It will <code>croak()</code> if accidentally called in a scalar context.</p> </dd> </li> <dt><strong><a name="print" class="item">print ( ARGS... )</a></strong> <dd> <p>Print ARGS to the file.</p> </dd> </li> <dt><strong><a name="read" class="item">read ( BUF, NBYTES, [OFFSET] )</a></strong> <dd> <p>Read some bytes from the file. Returns the number of bytes actually read, 0 on end-of-file, undef on error.</p> </dd> </li> <dt><strong><a name="eof" class="item">eof</a></strong> <dd> <p>Returns true if the handle is currently positioned at end of file?</p> </dd> </li> <dt><strong><a name="seek" class="item">seek ( OFFSET, WHENCE )</a></strong> <dd> <p>Seek to a given position in the stream. Not yet supported.</p> </dd> </li> <dt><strong><a name="tell" class="item">tell</a></strong> <dd> <p>Return the current position in the stream, as a numeric offset. Not yet supported.</p> </dd> </li> <dt><strong><a name="setpos" class="item">setpos ( POS )</a></strong> <dd> <p>Set the current position, using the opaque value returned by <a href="#getpos"><code>getpos()</code></a>. Not yet supported.</p> </dd> </li> <dt><strong><a name="getpos" class="item">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 class="file">gzip</em> is used, the following <a href="#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> use IO::Zlib ':gzip_read_open' => '/some/where/gunzip -c %s |'; use IO::Zlib ':gzip_write_open' => '| /some/where/gzip.exe > %s';</pre> <p>The <code>%s</code> is expanded to be the filename (<a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#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="has_compress_zlib" class="item">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="#gzip_external">gzip_external</a> and <a href="#gzip_used">gzip_used</a>.</p> </dd> </li> <dt><strong><a name="gzip_external" class="item">gzip_external</a></strong> <dd> <p>Undef if an external <em class="file">gzip</em> <strong>can</strong> be used if <code>Compress::Zlib</code> is not available (see <a href="#has_compress_zlib">has_Compress_Zlib</a>), true if an external <em class="file">gzip</em> is explicitly used, false if an external <em class="file">gzip</em> must not be used. See <a href="#gzip_used">gzip_used</a>.</p> </dd> </li> <dt><strong><a name="gzip_used" class="item">gzip_used</a></strong> <dd> <p>True if an external <em class="file">gzip</em> is being used, false if not.</p> </dd> </li> <dt><strong><a name="gzip_read_open" class="item">gzip_read_open</a></strong> <dd> <p>Return the 'command' being used for opening a file for reading using an external <em class="file">gzip</em>.</p> </dd> </li> <dt><strong><a name="gzip_write_open" class="item">gzip_write_open</a></strong> <dd> <p>Return the 'command' being used for opening a file for writing using an external <em class="file">gzip</em>.</p> </dd> </li> </dl> <p> </p> <hr /> <h1><a name="diagnostics">DIAGNOSTICS</a></h1> <dl> <dt><strong><a name="io_zlib_getlines_must_be_called_in_list_context" class="item">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="io_zlib_gzopen_external_mode_is_illegal" class="item">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="io_zlib_import_is_illegal" class="item">IO::Zlib::import: '...' is illegal</a></strong> <dd> <p>The known import symbols are the <a href="#gzip_external"><code>:gzip_external</code></a>, <a href="#gzip_read_open"><code>:gzip_read_open</code></a>, and <a href="#gzip_write_open"><code>:gzip_write_open</code></a>. Anything else is not recognized.</p> </dd> </li> <dt><strong><a name="io_zlib_import_gzip_external_requires_an_argument" class="item">IO::Zlib::import: ':gzip_external' requires an argument</a></strong> <dd> <p>The <a href="#gzip_external"><code>:gzip_external</code></a> requires one boolean argument.</p> </dd> </li> <dt><strong><a name="io_zlib_import_gzip_read_open_requires_an_argument" class="item">IO::Zlib::import: 'gzip_read_open' requires an argument</a></strong> <dd> <p>The <a href="#gzip_external"><code>:gzip_external</code></a> requires one string argument.</p> </dd> </li> <dt><strong><a name="io_zlib_import_gzip_read_is_illegal" class="item">IO::Zlib::import: 'gzip_read' '...' is illegal</a></strong> <dd> <p>The <a href="#gzip_read_open"><code>:gzip_read_open</code></a> 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="io_zlib_import_gzip_write_open_requires_an_argument" class="item">IO::Zlib::import: 'gzip_write_open' requires an argument</a></strong> <dd> <p>The <a href="#gzip_external"><code>:gzip_external</code></a> requires one string argument.</p> </dd> </li> <dt><strong><a name="io_zlib_import_gzip_write_open_is_illegal" class="item">IO::Zlib::import: 'gzip_write_open' '...' is illegal</a></strong> <dd> <p>The <a href="#gzip_write_open"><code>:gzip_write_open</code></a> 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="io_zlib_import_no_compress_zlib_and_no_external_gzip" class="item">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 class="file">gzip</em> was disabled, IO::Zlib has not much chance of working.</p> </dd> </li> <dt><strong><a name="io_zlib_open_needs_a_filename" class="item">IO::Zlib::open: needs a filename</a></strong> <dd> <p>No filename, no open.</p> </dd> </li> <dt><strong><a name="io_zlib_read_nbytes_must_be_specified" class="item">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="io_zlib_write_too_long_length" class="item">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="io_zlib_write_offset_is_not_supported" class="item">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="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html">the perlfunc manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlop.html#i_o_operators">I/O Operators in the perlop manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Handle.html">the IO::Handle manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/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 class="file"><a href="mailto:tom@compton.nu">tom@compton.nu</a></em>>.</p> <p>Support for external gzip added by Jarkko Hietaniemi <<em class="file"><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 class="file"><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> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> IO::Zlib - IO:: style interface to L<Compress::Zlib></span></strong></big> </td></tr> </table> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de