.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "gzip 3pm" .TH gzip 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME PerlIO::gzip \- Perl extension to provide a PerlIO layer to gzip/gunzip .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 3 \& use PerlIO::gzip; \& open FOO, "<:gzip", "file.gz" or die $!; \& print while ; # And it will be uncompressed... \& \& binmode FOO, ":gzip(none)" # Starts reading deflate stream from here on .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" PerlIO::gzip provides a PerlIO layer that manipulates files in the format used by the \f(CW\*(C`gzip\*(C'\fR program. Compression and Decompression are implemented, but not together. If you attempt to open a file for reading and writing the open will fail. .SH EXPORT .IX Header "EXPORT" PerlIO::gzip exports no subroutines or symbols, just a perl layer \f(CW\*(C`gzip\*(C'\fR .SH "LAYER ARGUMENTS" .IX Header "LAYER ARGUMENTS" The \f(CW\*(C`gzip\*(C'\fR layer takes a comma separated list of arguments. 4 exclusive options choose the header checking mode: .IP gzip 4 .IX Item "gzip" The default. Expects a standard gzip file header for reading, writes a standard gzip file header. .IP none 4 .IX Item "none" Expects or writes no file header; assumes the file handle is immediately a deflate stream (eg as would be found inside a \f(CW\*(C`zip\*(C'\fR file) .IP auto 4 .IX Item "auto" Potentially dangerous. If the first two bytes match the \f(CW\*(C`gzip\*(C'\fR header "\ex1f\ex8b" then a gzip header is assumed (and checked) else a deflate stream is assumed. No different from gzip on writing. .IP autopop 4 .IX Item "autopop" Potentially dangerous. If the first two bytes match the \f(CW\*(C`gzip\*(C'\fR header "\ex1f\ex8b" then a gzip header is assumed (and checked) else the layer is silently popped. This results in gzip files being transparently decompressed, other files being treated normally. Of course, this has sides effects such as File::Copy becoming gunzip, and File::Compare comparing the uncompressed contents of files. .Sp In autopop mode Opening a handle for writing (or reading and writing) will cause the gzip layer to automatically be popped. .PP Optionally you can add this flag: .IP lazy 4 .IX Item "lazy" For reading, defer header checking until the first read. For writing, don't write a header until the first buffer empty of compressed data to disk. (and don't write anything at all if no data was written to the handle) .Sp By default, gzip header checking is done before the \f(CW\*(C`open\*(C'\fR (or \f(CW\*(C`binmode\*(C'\fR) returns, so if an error is detected in the gzip header the \f(CW\*(C`open\*(C'\fR or \&\f(CW\*(C`binmode\*(C'\fR will fail. However, this will require reading some data, or writing a header. With lazy set on a file opened for reading the check is deferred until the first read so the \f(CW\*(C`open\*(C'\fR should always succeed, but any problems with the header will cause an error on read. .Sp .Vb 4 \& open FOO, "<:gzip(lazy)", "file.gz" or die $!; # Dangerous. \& while () { \& print; \& } # Whoa. Bad. You\*(Aqre not distinguishing between errors and EOF. .Ve .Sp If you're not careful you won't spot the errors \- like the example above you'll think you got end of file. .Sp lazy is ignored if you are in autopop mode. .SH AUTHOR .IX Header "AUTHOR" Nicholas Clark, .SH "SEE ALSO" .IX Header "SEE ALSO" perl, gzip, rfc 1952 (the gzip file format specification), rfc 1951 (DEFLATE compressed data format specification)