with a real filesystem file, like, say, an C<IO::String>.
In C<Compress::Zlib> version 2.x, the C<gzopen> interface has been
completely rewritten to use the L<IO::Compress::Gzip|IO::Compress::Gzip>
for writing gzip files and L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip>
for reading gzip files. None of the limitations mentioned above apply.
=item 3
Addition of C<gzseek> to provide a restricted C<seek> interface.
=item 4.
Added C<gztell>.
=back
A more complete and flexible interface for reading/writing gzip
files/buffers is included with the module C<IO-Compress-Zlib>. See
L<IO::Compress::Gzip|IO::Compress::Gzip> and
L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip> for more details.
=over 5
=item B<$gz = gzopen($filename, $mode)>
=item B<$gz = gzopen($filehandle, $mode)>
This function opens either the I<gzip> file C<$filename> for reading or
writing or attaches to the opened filehandle, C<$filehandle>.
It returns an object on success and C<undef> on failure.
When writing a gzip file this interface will I<always> create the smallest
possible gzip header (exactly 10 bytes). If you want greater control over
what gets stored in the gzip header (like the original filename or a
comment) use L<IO::Compress::Gzip|IO::Compress::Gzip> instead. Similarly if
you want to read the contents of the gzip header use
L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip>.
The second parameter, C<$mode>, is used to specify whether the file is
opened for reading or writing and to optionally specify a compression
level and compression strategy when writing. The format of the C<$mode>
parameter is similar to the mode parameter to the 'C' function C<fopen>,
so "rb" is used to open for reading, "wb" for writing and "ab" for
appending (writing at the end of the file).
To specify a compression level when writing, append a digit between 0
and 9 to the mode string -- 0 means no compression and 9 means maximum
compression.
If no compression level is specified Z_DEFAULT_COMPRESSION is used.
To specify the compression strategy when writing, append 'f' for filtered
data, 'h' for Huffman only compression, or 'R' for run-length encoding.
If no strategy is specified Z_DEFAULT_STRATEGY is used.
So, for example, "wb9" means open for writing with the maximum compression
using the default strategy and "wb4R" means open for writing with compression
level 4 and run-length encoding.
Refer to the I<zlib> documentation for the exact format of the C<$mode>
parameter.
=item B<$bytesread = $gz-E<gt>gzread($buffer [, $size]) ;>
Reads C<$size> bytes from the compressed file into C<$buffer>. If
C<$size> is not specified, it will default to 4096. If the scalar
C<$buffer> is not large enough, it will be extended automatically.
Returns the number of bytes actually read. On EOF it returns 0 and in
the case of an error, -1.
=item B<$bytesread = $gz-E<gt>gzreadline($line) ;>
Reads the next line from the compressed file into C<$line>.
Returns the number of bytes actually read. On EOF it returns 0 and in
the case of an error, -1.
It is legal to intermix calls to C<gzread> and C<gzreadline>.
To maintain backward compatibility with version 1.x of this module
C<gzreadline> ignores the C<$/> variable - it I<always> uses the string
C<"\n"> as the line delimiter.
If you want to read a gzip file a line at a time and have it respect the
C<$/> variable (or C<$INPUT_RECORD_SEPARATOR>, or C<$RS> when C<English> is
in use) see L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip>.
=item B<$byteswritten = $gz-E<gt>gzwrite($buffer) ;>
Writes the contents of C<$buffer> to the compressed file. Returns the
number of bytes actually written, or 0 on error.
=item B<$status = $gz-E<gt>gzflush($flush_type) ;>
Flushes all pending output into the compressed file.
This method takes an optional parameter, C<$flush_type>, that controls
how the flushing will be carried out. By default the C<$flush_type>
used is C<Z_FINISH>. Other valid values for C<$flush_type> are
=8= |