The behaviour of this option is dependent on the type of output data stream.

A Buffer

If Append is enabled, all compressed data will be append to the end of the output buffer. Otherwise the output buffer will be cleared before any compressed data is written to it.

A Filename

If Append 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.

A Filehandle

If Append is enabled, the filehandle will be positioned to the end of the file via a call to seek before any compressed data is written to it. Otherwise the file pointer will not be moved.

When Append is specified, and set to true, it will append all compressed data to the output data stream.

So when the output is a filehandle it will carry out a seek to the eof before writing any compressed data. If the output is a filename, it will be opened for appending. If the output is a buffer, all compressed data will be appended to the existing buffer.

Conversely when Append is not specified, or it is present and is set to false, it will operate as follows.

When the output is a filename, it will truncate the contents of the file before writing any compressed data. If the output is a filehandle its position will not be changed. If the output is a buffer, it will be wiped before any compressed data is output.

It returns an IO::Compress::Deflate object on success and undef on failure. The variable $DeflateError will contain an error message on failure.

If you are running Perl 5.005 or better the object, $z, returned from IO::Compress::Deflate can be used exactly like an IO::File filehandle. This means that all normal output file operations can be carried out with $z. For example, to write to a compressed file/buffer you can use either of these forms

$z->print("hello world\n");
print $z "hello world\n";

The mandatory parameter $output is used to control the destination of the compressed data. This parameter can take one of these forms.

This option is only valid when the $output parameter is a filehandle. If specified, and the value is true, it will result in the $output being closed once either the close method is called or the IO::Compress::Deflate object is destroyed.

This method takes an optional parameter, $flush_type, that controls how the flushing will be carried out. By default the $flush_type used is Z_FINISH. Other valid values for $flush_type are Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH and Z_BLOCK. It is strongly recommended that you only set the flush_type parameter if you fully understand the implications of what it does - overuse of flush can seriously degrade the level of compression achieved. See the zlib documentation for details.

If the $z object is associated with a file or a filehandle, this method returns the current autoflush setting for the underlying filehandle. If EXPR is present, and is non-zero, it will enable flushing after every write/print operation.

If $z is associated with a buffer, this method has no effect and always returns undef.

Note that the special variable $|cannot be used to set or retrieve the autoflush setting.

Flushes any pending compressed data and then closes the output file/buffer.

For most versions of Perl this method will be automatically invoked if the IO::Compress::Deflate 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 close method will be called automatically, but not until global destruction of all live objects when the program is terminating.

Therefore, if you want your scripts to be able to run on all versions of Perl, you should call close explicitly and not rely on automatic closing.

Returns true on success, otherwise 0.

If the AutoClose option has been enabled when the IO::Compress::Deflate object was created, and the object is associated with a file, the underlying file will also be closed.