Edit D:\app\Administrator\product\11.2.0\dbhome_1\perl\html\lib\IO\Compress\Gzip.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::Compress::Gzip - Write RFC 1952 files/buffers</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::Compress::Gzip - Write RFC 1952 files/buffers</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="#functional_interface">Functional Interface</a></li> <ul> <li><a href="#gzip__input_____output____opts_">gzip $input => $output [, OPTS]</a></li> <ul> <li><a href="#the__input_parameter">The <code>$input</code> parameter</a></li> <li><a href="#the__output_parameter">The <code>$output</code> parameter</a></li> </ul> <li><a href="#notes">Notes</a></li> <li><a href="#optional_parameters">Optional Parameters</a></li> <li><a href="#examples">Examples</a></li> </ul> <li><a href="#oo_interface">OO Interface</a></li> <ul> <li><a href="#constructor">Constructor</a></li> <li><a href="#constructor_options">Constructor Options</a></li> <li><a href="#examples">Examples</a></li> </ul> <li><a href="#methods">Methods</a></li> <ul> <li><a href="#print">print</a></li> <li><a href="#printf">printf</a></li> <li><a href="#syswrite">syswrite</a></li> <li><a href="#write">write</a></li> <li><a href="#flush">flush</a></li> <li><a href="#tell">tell</a></li> <li><a href="#eof">eof</a></li> <li><a href="#seek">seek</a></li> <li><a href="#binmode">binmode</a></li> <li><a href="#opened">opened</a></li> <li><a href="#autoflush">autoflush</a></li> <li><a href="#input_line_number">input_line_number</a></li> <li><a href="#fileno">fileno</a></li> <li><a href="#close">close</a></li> <li><a href="#newstream__opts__">newStream([OPTS])</a></li> <li><a href="#deflateparams">deflateParams</a></li> </ul> <li><a href="#importing">Importing</a></li> <li><a href="#examples">EXAMPLES</a></li> <li><a href="#see_also">SEE ALSO</a></li> <li><a href="#author">AUTHOR</a></li> <li><a href="#modification_history">MODIFICATION HISTORY</a></li> <li><a href="#copyright_and_license">COPYRIGHT AND LICENSE</a></li> </ul> <hr name="index" /> </div> <!-- INDEX END --> <p> </p> <h1><a name="name">NAME</a></h1> <p>IO::Compress::Gzip - Write <a href="http://www.ietf.org/rfc/rfc1952.txt" class="rfc">RFC 1952</a> files/buffers</p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <pre> use IO::Compress::Gzip qw(gzip $GzipError) ;</pre> <pre> my $status = gzip $input => $output [,OPTS] or die "gzip failed: $GzipError\n";</pre> <pre> my $z = new IO::Compress::Gzip $output [,OPTS] or die "gzip failed: $GzipError\n";</pre> <pre> $z->print($string); $z->printf($format, $string); $z->write($string); $z->syswrite($string [, $length, $offset]); $z->flush(); $z->tell(); $z->eof(); $z->seek($position, $whence); $z->binmode(); $z->fileno(); $z->opened(); $z->autoflush(); $z->input_line_number(); $z->newStream( [OPTS] ); $z->deflateParams(); $z->close() ;</pre> <pre> $GzipError ;</pre> <pre> # IO::File mode</pre> <pre> print $z $string; printf $z $format, $string; tell $z eof $z seek $z, $position, $whence binmode $z fileno $z close $z ;</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p>This module provides a Perl interface that allows writing compressed data to files or buffer as defined in <a href="http://www.ietf.org/rfc/rfc1952.txt" class="rfc">RFC 1952</a>.</p> <p>All the gzip headers defined in <a href="http://www.ietf.org/rfc/rfc1952.txt" class="rfc">RFC 1952</a> can be created using this module.</p> <p>For reading <a href="http://www.ietf.org/rfc/rfc1952.txt" class="rfc">RFC 1952</a> files/buffers, see the companion module <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/Gunzip.html">IO::Uncompress::Gunzip</a>.</p> <p> </p> <hr /> <h1><a name="functional_interface">Functional Interface</a></h1> <p>A top-level function, <code>gzip</code>, is provided to carry out "one-shot" compression between buffers and/or files. For finer control over the compression process, see the <a href="#oo_interface">OO Interface</a> section.</p> <pre> use IO::Compress::Gzip qw(gzip $GzipError) ;</pre> <pre> gzip $input => $output [,OPTS] or die "gzip failed: $GzipError\n";</pre> <p>The functional interface needs Perl5.005 or better.</p> <p> </p> <h2><a name="gzip__input_____output____opts_">gzip $input => $output [, OPTS]</a></h2> <p><code>gzip</code> expects at least two parameters, <code>$input</code> and <code>$output</code>.</p> <p> </p> <h3><a name="the__input_parameter">The <code>$input</code> parameter</a></h3> <p>The parameter, <code>$input</code>, is used to define the source of the uncompressed data.</p> <p>It can take one of the following forms:</p> <dl> <dt><strong><a name="a_filename4" class="item">A filename</a></strong> <dd> <p>If the <code>$input</code> parameter is a simple scalar, it is assumed to be a filename. This file will be opened for reading and the input data will be read from it.</p> </dd> </li> <dt><strong><a name="a_filehandle4" class="item">A filehandle</a></strong> <dd> <p>If the <code>$input</code> parameter is a filehandle, the input data will be read from it. The string '-' can be used as an alias for standard input.</p> </dd> </li> <dt><strong><a name="a_scalar_reference4" class="item">A scalar reference</a></strong> <dd> <p>If <code>$input</code> is a scalar reference, the input data will be read from <code>$$input</code>.</p> </dd> </li> <dt><strong><a name="an_array_reference2" class="item">An array reference</a></strong> <dd> <p>If <code>$input</code> is an array reference, each element in the array must be a filename.</p> </dd> <dd> <p>The input data will be read from each file in turn.</p> </dd> <dd> <p>The complete array will be walked to ensure that it only contains valid filenames before any data is compressed.</p> </dd> </li> <dt><strong><a name="an_input_fileglob_string2" class="item">An Input FileGlob string</a></strong> <dd> <p>If <code>$input</code> is a string that is delimited by the characters "<" and ">" <code>gzip</code> will assume that it is an <em>input fileglob string</em>. The input is the list of files that match the fileglob.</p> </dd> <dd> <p>If the fileglob does not match any files ...</p> </dd> <dd> <p>See <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/File/GlobMapper.html">File::GlobMapper</a> for more details.</p> </dd> </li> </dl> <p>If the <code>$input</code> parameter is any other type, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#undef"><code>undef</code></a> will be returned.</p> <p>In addition, if <code>$input</code> is a simple filename, the default values for the <code>Name</code> and <code>Time</code> options will be sourced from that file.</p> <p>If you do not want to use these defaults they can be overridden by explicitly setting the <code>Name</code> and <code>Time</code> options or by setting the <code>Minimal</code> parameter.</p> <p> </p> <h3><a name="the__output_parameter">The <code>$output</code> parameter</a></h3> <p>The parameter <code>$output</code> is used to control the destination of the compressed data. This parameter can take one of these forms.</p> <dl> <dt><strong><a name="a_filename5" class="item">A filename</a></strong> <dd> <p>If the <code>$output</code> parameter is a simple scalar, it is assumed to be a filename. This file will be opened for writing and the compressed data will be written to it.</p> </dd> </li> <dt><strong><a name="a_filehandle5" class="item">A filehandle</a></strong> <dd> <p>If the <code>$output</code> parameter is a filehandle, the compressed data will be written to it. The string '-' can be used as an alias for standard output.</p> </dd> </li> <dt><strong><a name="a_scalar_reference5" class="item">A scalar reference</a></strong> <dd> <p>If <code>$output</code> is a scalar reference, the compressed data will be stored in <code>$$output</code>.</p> </dd> </li> <dt><strong><a name="an_array_reference2" class="item">An Array Reference</a></strong> <dd> <p>If <code>$output</code> is an array reference, the compressed data will be pushed onto the array.</p> </dd> </li> <dt><strong><a name="an_output_fileglob2" class="item">An Output FileGlob</a></strong> <dd> <p>If <code>$output</code> is a string that is delimited by the characters "<" and ">" <code>gzip</code> will assume that it is an <em>output fileglob string</em>. The output is the list of files that match the fileglob.</p> </dd> <dd> <p>When <code>$output</code> is an fileglob string, <code>$input</code> must also be a fileglob string. Anything else is an error.</p> </dd> </li> </dl> <p>If the <code>$output</code> parameter is any other type, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#undef"><code>undef</code></a> will be returned.</p> <p> </p> <h2><a name="notes">Notes</a></h2> <p>When <code>$input</code> maps to multiple files/buffers and <code>$output</code> is a single file/buffer the input files/buffers will be stored in <code>$output</code> as a concatenated series of compressed data streams.</p> <p> </p> <h2><a name="optional_parameters">Optional Parameters</a></h2> <p>Unless specified below, the optional parameters for <code>gzip</code>, <code>OPTS</code>, are the same as those used with the OO interface defined in the <a href="#constructor_options">Constructor Options</a> section below.</p> <dl> <dt><strong><a name="autoclose_0_13" class="item"><a href="#autoclose_0_1"><code>AutoClose => 0|1</code></a></a></strong> <dd> <p>This option applies to any input or output data streams to <code>gzip</code> that are filehandles.</p> </dd> <dd> <p>If <code>AutoClose</code> is specified, and the value is true, it will result in all input and/or output filehandles being closed once <code>gzip</code> has completed.</p> </dd> <dd> <p>This parameter defaults to 0.</p> </dd> </li> <dt><strong><a name="binmodein_0_12" class="item"><a href="#binmodein_0_1"><code>BinModeIn => 0|1</code></a></a></strong> <dd> <p>When reading from a file or filehandle, set <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#binmode"><code>binmode</code></a> before reading.</p> </dd> <dd> <p>Defaults to 0.</p> </dd> </li> <dt><strong><a name="append_0_13" class="item"><a href="#append_0_1"><code>Append => 0|1</code></a></a></strong> <dd> <p>TODO</p> </dd> </li> </dl> <p> </p> <h2><a name="examples">Examples</a></h2> <p>To read the contents of the file <code>file1.txt</code> and write the compressed data to the file <code>file1.txt.gz</code>.</p> <pre> use strict ; use warnings ; use IO::Compress::Gzip qw(gzip $GzipError) ;</pre> <pre> my $input = "file1.txt"; gzip $input => "$input.gz" or die "gzip failed: $GzipError\n";</pre> <p>To read from an existing Perl filehandle, <code>$input</code>, and write the compressed data to a buffer, <code>$buffer</code>.</p> <pre> use strict ; use warnings ; use IO::Compress::Gzip qw(gzip $GzipError) ; use IO::File ;</pre> <pre> my $input = new IO::File "<file1.txt" or die "Cannot open 'file1.txt': $!\n" ; my $buffer ; gzip $input => \$buffer or die "gzip failed: $GzipError\n";</pre> <p>To compress all files in the directory "/my/home" that match "*.txt" and store the compressed data in the same directory</p> <pre> use strict ; use warnings ; use IO::Compress::Gzip qw(gzip $GzipError) ;</pre> <pre> gzip '</my/home/*.txt>' => '<*.gz>' or die "gzip failed: $GzipError\n";</pre> <p>and if you want to compress each file one at a time, this will do the trick</p> <pre> use strict ; use warnings ; use IO::Compress::Gzip qw(gzip $GzipError) ;</pre> <pre> for my $input ( glob "/my/home/*.txt" ) { my $output = "$input.gz" ; gzip $input => $output or die "Error compressing '$input': $GzipError\n"; }</pre> <p> </p> <hr /> <h1><a name="oo_interface">OO Interface</a></h1> <p> </p> <h2><a name="constructor">Constructor</a></h2> <p>The format of the constructor for <code>IO::Compress::Gzip</code> is shown below</p> <pre> my $z = new IO::Compress::Gzip $output [,OPTS] or die "IO::Compress::Gzip failed: $GzipError\n";</pre> <p>It returns an <code>IO::Compress::Gzip</code> object on success and undef on failure. The variable <code>$GzipError</code> will contain an error message on failure.</p> <p>If you are running Perl 5.005 or better the object, <code>$z</code>, returned from IO::Compress::Gzip can be used exactly like an <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/File.html">IO::File</a> filehandle. This means that all normal output file operations can be carried out with <code>$z</code>. For example, to write to a compressed file/buffer you can use either of these forms</p> <pre> $z->print("hello world\n"); print $z "hello world\n";</pre> <p>The mandatory parameter <code>$output</code> is used to control the destination of the compressed data. This parameter can take one of these forms.</p> <dl> <dt><strong><a name="a_filename6" class="item">A filename</a></strong> <dd> <p>If the <code>$output</code> parameter is a simple scalar, it is assumed to be a filename. This file will be opened for writing and the compressed data will be written to it.</p> </dd> </li> <dt><strong><a name="a_filehandle6" class="item">A filehandle</a></strong> <dd> <p>If the <code>$output</code> parameter is a filehandle, the compressed data will be written to it. The string '-' can be used as an alias for standard output.</p> </dd> </li> <dt><strong><a name="a_scalar_reference6" class="item">A scalar reference</a></strong> <dd> <p>If <code>$output</code> is a scalar reference, the compressed data will be stored in <code>$$output</code>.</p> </dd> </li> </dl> <p>If the <code>$output</code> parameter is any other type, <code>IO::Compress::Gzip</code>::new will return undef.</p> <p> </p> <h2><a name="constructor_options">Constructor Options</a></h2> <p><code>OPTS</code> is any combination of the following options:</p> <dl> <dt><strong><a name="autoclose_0_14" class="item"><a href="#autoclose_0_1"><code>AutoClose => 0|1</code></a></a></strong> <dd> <p>This option is only valid when the <code>$output</code> parameter is a filehandle. If specified, and the value is true, it will result in the <code>$output</code> being closed once either the <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#close"><code>close</code></a> method is called or the <code>IO::Compress::Gzip</code> object is destroyed.</p> </dd> <dd> <p>This parameter defaults to 0.</p> </dd> </li> <dt><strong><a name="append_0_14" class="item"><a href="#append_0_1"><code>Append => 0|1</code></a></a></strong> <dd> <p>Opens <code>$output</code> in append mode.</p> </dd> <dd> <p>The behaviour of this option is dependent on the type of <code>$output</code>.</p> </dd> <ul> <li><strong><a name="a_buffer2" class="item">A Buffer</a></strong> <p>If <code>$output</code> is a buffer and <code>Append</code> is enabled, all compressed data will be append to the end if <code>$output</code>. Otherwise <code>$output</code> will be cleared before any data is written to it.</p> </li> <li><strong><a name="a_filename2" class="item">A Filename</a></strong> <p>If <code>$output</code> is a filename and <code>Append</code> is enabled, the file will be opened in append mode. Otherwise the contents of the file, if any, will be truncated before any compressed data is written to it.</p> </li> <li><strong><a name="a_filehandle2" class="item">A Filehandle</a></strong> <p>If <code>$output</code> is a filehandle, the file pointer will be positioned to the end of the file via a call to <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#seek"><code>seek</code></a> before any compressed data is written to it. Otherwise the file pointer will not be moved.</p> </li> </ul> <p>This parameter defaults to 0.</p> <dt><strong><a name="merge_0_12" class="item"><a href="#merge_0_1"><code>Merge => 0|1</code></a></a></strong> <dd> <p>This option is used to compress input data and append it to an existing compressed data stream in <code>$output</code>. The end result is a single compressed data stream stored in <code>$output</code>.</p> </dd> <dd> <p>It is a fatal error to attempt to use this option when <code>$output</code> is not an <a href="http://www.ietf.org/rfc/rfc1952.txt" class="rfc">RFC 1952</a> data stream.</p> </dd> <dd> <p>There are a number of other limitations with the <code>Merge</code> option:</p> </dd> <ol> <li> <p>This module needs to have been built with zlib 1.2.1 or better to work. A fatal error will be thrown if <code>Merge</code> is used with an older version of zlib.</p> </li> <li> <p>If <code>$output</code> is a file or a filehandle, it must be seekable.</p> </li> </ol> <p>This parameter defaults to 0.</p> <dt><strong><a name="level6" class="item">-Level</a></strong> <dd> <p>Defines the compression level used by zlib. The value should either be a number between 0 and 9 (0 means no compression and 9 is maximum compression), or one of the symbolic constants defined below.</p> </dd> <dd> <pre> Z_NO_COMPRESSION Z_BEST_SPEED Z_BEST_COMPRESSION Z_DEFAULT_COMPRESSION</pre> </dd> <dd> <p>The default is Z_DEFAULT_COMPRESSION.</p> </dd> <dd> <p>Note, these constants are not imported by <code>IO::Compress::Gzip</code> by default.</p> </dd> <dd> <pre> use IO::Compress::Gzip qw(:strategy); use IO::Compress::Gzip qw(:constants); use IO::Compress::Gzip qw(:all);</pre> </dd> </li> <dt><strong><a name="strategy6" class="item">-Strategy</a></strong> <dd> <p>Defines the strategy used to tune the compression. Use one of the symbolic constants defined below.</p> </dd> <dd> <pre> Z_FILTERED Z_HUFFMAN_ONLY Z_RLE Z_FIXED Z_DEFAULT_STRATEGY</pre> </dd> <dd> <p>The default is Z_DEFAULT_STRATEGY.</p> </dd> </li> <dt><strong><a name="minimal_0_1" class="item"><code>Minimal => 0|1</code></a></strong> <dd> <p>If specified, this option will force the creation of the smallest possible compliant gzip header (which is exactly 10 bytes long) as defined in <a href="http://www.ietf.org/rfc/rfc1952.txt" class="rfc">RFC 1952</a>.</p> </dd> <dd> <p>See the section titled "Compliance" in <a href="http://www.ietf.org/rfc/rfc1952.txt" class="rfc">RFC 1952</a> for a definition of the values used for the fields in the gzip header.</p> </dd> <dd> <p>All other parameters that control the content of the gzip header will be ignored if this parameter is set to 1.</p> </dd> <dd> <p>This parameter defaults to 0.</p> </dd> </li> <dt><strong><a name="comment_comment" class="item"><code>Comment => $comment</code></a></strong> <dd> <p>Stores the contents of <code>$comment</code> in the COMMENT field in the gzip header. By default, no comment field is written to the gzip file.</p> </dd> <dd> <p>If the <code>-Strict</code> option is enabled, the comment can only consist of ISO 8859-1 characters plus line feed.</p> </dd> <dd> <p>If the <code>-Strict</code> option is disabled, the comment field can contain any character except NULL. If any null characters are present, the field will be truncated at the first NULL.</p> </dd> </li> <dt><strong><a name="name_string" class="item"><code>Name => $string</code></a></strong> <dd> <p>Stores the contents of <code>$string</code> in the gzip NAME header field. If <code>Name</code> is not specified, no gzip NAME field will be created.</p> </dd> <dd> <p>If the <code>-Strict</code> option is enabled, <code>$string</code> can only consist of ISO 8859-1 characters.</p> </dd> <dd> <p>If <code>-Strict</code> is disabled, then <code>$string</code> can contain any character except NULL. If any null characters are present, the field will be truncated at the first NULL.</p> </dd> </li> <dt><strong><a name="time_number" class="item"><code>Time => $number</code></a></strong> <dd> <p>Sets the MTIME field in the gzip header to $number.</p> </dd> <dd> <p>This field defaults to the time the <code>IO::Compress::Gzip</code> object was created if this option is not specified.</p> </dd> </li> <dt><strong><a name="textflag_0_1" class="item"><code>TextFlag => 0|1</code></a></strong> <dd> <p>This parameter controls the setting of the FLG.FTEXT bit in the gzip header. It is used to signal that the data stored in the gzip file/buffer is probably text.</p> </dd> <dd> <p>The default is 0.</p> </dd> </li> <dt><strong><a name="headercrc_0_1" class="item"><code>HeaderCRC => 0|1</code></a></strong> <dd> <p>When true this parameter will set the FLG.FHCRC bit to 1 in the gzip header and set the CRC16 header field to the CRC of the complete gzip header except the CRC16 field itself.</p> </dd> <dd> <p><strong>Note</strong> that gzip files created with the <code>HeaderCRC</code> flag set to 1 cannot be read by most, if not all, of the the standard gunzip utilities, most notably gzip version 1.2.4. You should therefore avoid using this option if you want to maximize the portability of your gzip files.</p> </dd> <dd> <p>This parameter defaults to 0.</p> </dd> </li> <dt><strong><a name="os_code_value" class="item"><code>OS_Code => $value</code></a></strong> <dd> <p>Stores <code>$value</code> in the gzip OS header field. A number between 0 and 255 is valid.</p> </dd> <dd> <p>If not specified, this parameter defaults to the OS code of the Operating System this module was built on. The value 3 is used as a catch-all for all Unix variants and unknown Operating Systems.</p> </dd> </li> <dt><strong><a name="extrafield_data" class="item"><code>ExtraField => $data</code></a></strong> <dd> <p>This parameter allows additional metadata to be stored in the ExtraField in the gzip header. An <a href="http://www.ietf.org/rfc/rfc1952.txt" class="rfc">RFC 1952</a> compliant ExtraField consists of zero or more subfields. Each subfield consists of a two byte header followed by the subfield data.</p> </dd> <dd> <p>The list of subfields can be supplied in any of the following formats</p> </dd> <dd> <pre> -ExtraField => [$id1, $data1, $id2, $data2, ... ] -ExtraField => [ [$id1 => $data1], [$id2 => $data2], ... ] -ExtraField => { $id1 => $data1, $id2 => $data2, ... }</pre> </dd> <dd> <p>Where <code>$id1</code>, <code>$id2</code> are two byte subfield ID's. The second byte of the ID cannot be 0, unless the <code>Strict</code> option has been disabled.</p> </dd> <dd> <p>If you use the hash syntax, you have no control over the order in which the ExtraSubFields are stored, plus you cannot have SubFields with duplicate ID.</p> </dd> <dd> <p>Alternatively the list of subfields can by supplied as a scalar, thus</p> </dd> <dd> <pre> -ExtraField => $rawdata</pre> </dd> <dd> <p>If you use the raw format, and the <code>Strict</code> option is enabled, <code>IO::Compress::Gzip</code> will check that <code>$rawdata</code> consists of zero or more conformant sub-fields. When <code>Strict</code> is disabled, <code>$rawdata</code> can consist of any arbitrary byte stream.</p> </dd> <dd> <p>The maximum size of the Extra Field 65535 bytes.</p> </dd> </li> <dt><strong><a name="extraflags_value" class="item"><code>ExtraFlags => $value</code></a></strong> <dd> <p>Sets the XFL byte in the gzip header to <code>$value</code>.</p> </dd> <dd> <p>If this option is not present, the value stored in XFL field will be determined by the setting of the <a href="#level"><code>Level</code></a> option.</p> </dd> <dd> <p>If <code>Level => Z_BEST_SPEED</code> has been specified then XFL is set to 2. If <code>Level => Z_BEST_COMPRESSION</code> has been specified then XFL is set to 4. Otherwise XFL is set to 0.</p> </dd> </li> <dt><strong><a name="strict_0_12" class="item"><a href="#strict_0_1"><code>Strict => 0|1</code></a></a></strong> <dd> <p><code>Strict</code> will optionally police the values supplied with other options to ensure they are compliant with <a href="http://www.ietf.org/rfc/rfc1952.txt" class="rfc">RFC1952</a>.</p> </dd> <dd> <p>This option is enabled by default.</p> </dd> <dd> <p>If <code>Strict</code> is enabled the following behaviour will be policed:</p> </dd> <ul> <li> <p>The value supplied with the <code>Name</code> option can only contain ISO 8859-1 characters.</p> </li> <li> <p>The value supplied with the <code>Comment</code> option can only contain ISO 8859-1 characters plus line-feed.</p> </li> <li> <p>The values supplied with the <code>-Name</code> and <code>-Comment</code> options cannot contain multiple embedded nulls.</p> </li> <li> <p>If an <code>ExtraField</code> option is specified and it is a simple scalar, it must conform to the sub-field structure as defined in <a href="http://www.ietf.org/rfc/rfc1952.txt" class="rfc">RFC 1952</a>.</p> </li> <li> <p>If an <code>ExtraField</code> option is specified the second byte of the ID will be checked in each subfield to ensure that it does not contain the reserved value 0x00.</p> </li> </ul> <p>When <code>Strict</code> is disabled the following behaviour will be policed:</p> <ul> <li> <p>The value supplied with <code>-Name</code> option can contain any character except NULL.</p> </li> <li> <p>The value supplied with <code>-Comment</code> option can contain any character except NULL.</p> </li> <li> <p>The values supplied with the <code>-Name</code> and <code>-Comment</code> options can contain multiple embedded nulls. The string written to the gzip header will consist of the characters up to, but not including, the first embedded NULL.</p> </li> <li> <p>If an <code>ExtraField</code> option is specified and it is a simple scalar, the structure will not be checked. The only error is if the length is too big.</p> </li> <li> <p>The ID header in an <code>ExtraField</code> sub-field can consist of any two bytes.</p> </li> </ul> </dl> <p> </p> <h2><a name="examples">Examples</a></h2> <p>TODO</p> <p> </p> <hr /> <h1><a name="methods">Methods</a></h1> <p> </p> <h2><a name="print">print</a></h2> <p>Usage is</p> <pre> $z->print($data) print $z $data</pre> <p>Compresses and outputs the contents of the <code>$data</code> parameter. This has the same behaviour as the <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#print"><code>print</code></a> built-in.</p> <p>Returns true if successful.</p> <p> </p> <h2><a name="printf">printf</a></h2> <p>Usage is</p> <pre> $z->printf($format, $data) printf $z $format, $data</pre> <p>Compresses and outputs the contents of the <code>$data</code> parameter.</p> <p>Returns true if successful.</p> <p> </p> <h2><a name="syswrite">syswrite</a></h2> <p>Usage is</p> <pre> $z->syswrite $data $z->syswrite $data, $length $z->syswrite $data, $length, $offset</pre> <p>Compresses and outputs the contents of the <code>$data</code> parameter.</p> <p>Returns the number of uncompressed bytes written, or <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#undef"><code>undef</code></a> if unsuccessful.</p> <p> </p> <h2><a name="write">write</a></h2> <p>Usage is</p> <pre> $z->write $data $z->write $data, $length $z->write $data, $length, $offset</pre> <p>Compresses and outputs the contents of the <code>$data</code> parameter.</p> <p>Returns the number of uncompressed bytes written, or <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#undef"><code>undef</code></a> if unsuccessful.</p> <p> </p> <h2><a name="flush">flush</a></h2> <p>Usage is</p> <pre> $z->flush; $z->flush($flush_type);</pre> <p>Flushes any pending compressed data to the output file/buffer.</p> <p>This method takes an optional parameter, <code>$flush_type</code>, that controls how the flushing will be carried out. By default the <code>$flush_type</code> used is <code>Z_FINISH</code>. Other valid values for <code>$flush_type</code> are <code>Z_NO_FLUSH</code>, <code>Z_SYNC_FLUSH</code>, <code>Z_FULL_FLUSH</code> and <code>Z_BLOCK</code>. It is strongly recommended that you only set the <code>flush_type</code> parameter if you fully understand the implications of what it does - overuse of <a href="#flush"><code>flush</code></a> can seriously degrade the level of compression achieved. See the <code>zlib</code> documentation for details.</p> <p>Returns true on success.</p> <p> </p> <h2><a name="tell">tell</a></h2> <p>Usage is</p> <pre> $z->tell() tell $z</pre> <p>Returns the uncompressed file offset.</p> <p> </p> <h2><a name="eof">eof</a></h2> <p>Usage is</p> <pre> $z->eof(); eof($z);</pre> <p>Returns true if the <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#close"><code>close</code></a> method has been called.</p> <p> </p> <h2><a name="seek">seek</a></h2> <pre> $z->seek($position, $whence); seek($z, $position, $whence);</pre> <p>Provides a sub-set of the <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#seek"><code>seek</code></a> functionality, with the restriction that it is only legal to seek forward in the output file/buffer. It is a fatal error to attempt to seek backward.</p> <p>Empty parts of the file/buffer will have NULL (0x00) bytes written to them.</p> <p>The <code>$whence</code> parameter takes one the usual values, namely SEEK_SET, SEEK_CUR or SEEK_END.</p> <p>Returns 1 on success, 0 on failure.</p> <p> </p> <h2><a name="binmode">binmode</a></h2> <p>Usage is</p> <pre> $z->binmode binmode $z ;</pre> <p>This is a noop provided for completeness.</p> <p> </p> <h2><a name="opened">opened</a></h2> <pre> $z->opened()</pre> <p>Returns true if the object currently refers to a opened file/buffer.</p> <p> </p> <h2><a name="autoflush">autoflush</a></h2> <pre> my $prev = $z->autoflush() my $prev = $z->autoflush(EXPR)</pre> <p>If the <code>$z</code> object is associated with a file or a filehandle, this method returns the current autoflush setting for the underlying filehandle. If <code>EXPR</code> is present, and is non-zero, it will enable flushing after every write/print operation.</p> <p>If <code>$z</code> is associated with a buffer, this method has no effect and always returns <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#undef"><code>undef</code></a>.</p> <p><strong>Note</strong> that the special variable <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlvar.html#__"><code>$|</code></a> <strong>cannot</strong> be used to set or retrieve the autoflush setting.</p> <p> </p> <h2><a name="input_line_number">input_line_number</a></h2> <pre> $z->input_line_number() $z->input_line_number(EXPR)</pre> <p>This method always returns <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#undef"><code>undef</code></a> when compressing.</p> <p> </p> <h2><a name="fileno">fileno</a></h2> <pre> $z->fileno() fileno($z)</pre> <p>If the <code>$z</code> object is associated with a file or a filehandle, this method will return the underlying file descriptor.</p> <p>If the <code>$z</code> object is is associated with a buffer, this method will return undef.</p> <p> </p> <h2><a name="close">close</a></h2> <pre> $z->close() ; close $z ;</pre> <p>Flushes any pending compressed data and then closes the output file/buffer.</p> <p>For most versions of Perl this method will be automatically invoked if the IO::Compress::Gzip object is destroyed (either explicitly or by the variable with the reference to the object going out of scope). The exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In these cases, the <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#close"><code>close</code></a> method will be called automatically, but not until global destruction of all live objects when the program is terminating.</p> <p>Therefore, if you want your scripts to be able to run on all versions of Perl, you should call <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#close"><code>close</code></a> explicitly and not rely on automatic closing.</p> <p>Returns true on success, otherwise 0.</p> <p>If the <code>AutoClose</code> option has been enabled when the IO::Compress::Gzip object was created, and the object is associated with a file, the underlying file will also be closed.</p> <p> </p> <h2><a name="newstream__opts__">newStream([OPTS])</a></h2> <p>Usage is</p> <pre> $z->newStream( [OPTS] )</pre> <p>Closes the current compressed data stream and starts a new one.</p> <p>OPTS consists of any of the the options that are available when creating the <code>$z</code> object.</p> <p>See the <a href="#constructor_options">Constructor Options</a> section for more details.</p> <p> </p> <h2><a name="deflateparams">deflateParams</a></h2> <p>Usage is</p> <pre> $z->deflateParams</pre> <p>TODO</p> <p> </p> <hr /> <h1><a name="importing">Importing</a></h1> <p>A number of symbolic constants are required by some methods in <code>IO::Compress::Gzip</code>. None are imported by default.</p> <dl> <dt><strong><a name="all3" class="item">:all</a></strong> <dd> <p>Imports <code>gzip</code>, <code>$GzipError</code> and all symbolic constants that can be used by <code>IO::Compress::Gzip</code>. Same as doing this</p> </dd> <dd> <pre> use IO::Compress::Gzip qw(gzip $GzipError :constants) ;</pre> </dd> </li> <dt><strong><a name="constants2" class="item">:constants</a></strong> <dd> <p>Import all symbolic constants. Same as doing this</p> </dd> <dd> <pre> use IO::Compress::Gzip qw(:flush :level :strategy) ;</pre> </dd> </li> <dt><strong><a name="flush2" class="item">:flush</a></strong> <dd> <p>These symbolic constants are used by the <a href="#flush"><code>flush</code></a> method.</p> </dd> <dd> <pre> Z_NO_FLUSH Z_PARTIAL_FLUSH Z_SYNC_FLUSH Z_FULL_FLUSH Z_FINISH Z_BLOCK</pre> </dd> </li> <dt><strong><a name="level2" class="item">:level</a></strong> <dd> <p>These symbolic constants are used by the <a href="#level"><code>Level</code></a> option in the constructor.</p> </dd> <dd> <pre> Z_NO_COMPRESSION Z_BEST_SPEED Z_BEST_COMPRESSION Z_DEFAULT_COMPRESSION</pre> </dd> </li> <dt><strong><a name="strategy2" class="item">:strategy</a></strong> <dd> <p>These symbolic constants are used by the <a href="#strategy"><code>Strategy</code></a> option in the constructor.</p> </dd> <dd> <pre> Z_FILTERED Z_HUFFMAN_ONLY Z_RLE Z_FIXED Z_DEFAULT_STRATEGY</pre> </dd> <dd> <p></p> </dd> </li> </dl> <p>For</p> <p> </p> <hr /> <h1><a name="examples">EXAMPLES</a></h1> <p>TODO</p> <p> </p> <hr /> <h1><a name="see_also">SEE ALSO</a></h1> <p><a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/Compress/Zlib.html">the Compress::Zlib manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/Gunzip.html">the IO::Uncompress::Gunzip manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Compress/Deflate.html">the IO::Compress::Deflate manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/Inflate.html">the IO::Uncompress::Inflate manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Compress/RawDeflate.html">the IO::Compress::RawDeflate manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/RawInflate.html">the IO::Uncompress::RawInflate manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Compress/Bzip2.html">the IO::Compress::Bzip2 manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Uncompress/Bunzip2.html">the IO::Uncompress::Bunzip2 manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Compress/Lzop.html">the IO::Compress::Lzop manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Uncompress/UnLzop.html">the IO::Uncompress::UnLzop manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Compress/Lzf.html">the IO::Compress::Lzf manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Uncompress/UnLzf.html">the IO::Uncompress::UnLzf manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/AnyInflate.html">the IO::Uncompress::AnyInflate manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/AnyUncompress.html">the IO::Uncompress::AnyUncompress manpage</a></p> <p><a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/Compress/Zlib/FAQ.html">Compress::Zlib::FAQ</a></p> <p><a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/File/GlobMapper.html">File::GlobMapper</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/Archive/Zip.html">Archive::Zip</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/Archive/Tar.html">Archive::Tar</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Zlib.html">IO::Zlib</a></p> <p>For <a href="http://www.ietf.org/rfc/rfc1950.txt" class="rfc">RFC 1950</a>, 1951 and 1952 see <em class="file"><a href="http://www.faqs.org/rfcs/rfc1950.html">http://www.faqs.org/rfcs/rfc1950.html</a></em>, <em class="file"><a href="http://www.faqs.org/rfcs/rfc1951.html">http://www.faqs.org/rfcs/rfc1951.html</a></em> and <em class="file"><a href="http://www.faqs.org/rfcs/rfc1952.html">http://www.faqs.org/rfcs/rfc1952.html</a></em></p> <p>The <em>zlib</em> compression library was written by Jean-loup Gailly <em class="file"><a href="mailto:gzip@prep.ai.mit.edu">gzip@prep.ai.mit.edu</a></em> and Mark Adler <em class="file"><a href="mailto:madler@alumni.caltech.edu">madler@alumni.caltech.edu</a></em>.</p> <p>The primary site for the <em>zlib</em> compression library is <em class="file"><a href="http://www.zlib.org">http://www.zlib.org</a></em>.</p> <p>The primary site for gzip is <em class="file"><a href="http://www.gzip.org">http://www.gzip.org</a></em>.</p> <p> </p> <hr /> <h1><a name="author">AUTHOR</a></h1> <p>This module was written by Paul Marquess, <em class="file"><a href="mailto:pmqs@cpan.org">pmqs@cpan.org</a></em>.</p> <p> </p> <hr /> <h1><a name="modification_history">MODIFICATION HISTORY</a></h1> <p>See the Changes file.</p> <p> </p> <hr /> <h1><a name="copyright_and_license">COPYRIGHT AND LICENSE</a></h1> <p>Copyright (c) 2005-2007 Paul Marquess. All rights reserved.</p> <p>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::Compress::Gzip - Write RFC 1952 files/buffers</span></strong></big> </td></tr> </table> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de