gzip(3)
π NAME π
okay so bestie, this is the gzip(3) page from User Contributed Perl Documentation β and it's all about PerlIO::gzip, the Perl extension that gives you a PerlIO layer to gzip/gunzip. slay β¨
πΈ SYNOPSIS πΈ
use PerlIO::gzip;
open FOO, "<:gzip", "file.gz" or die $!;
print while <FOO>; # And it will be uncompressed...
binmode FOO, ":gzip(none)" # Starts reading deflate stream from here on
π DESCRIPTION π
PerlIO::gzip provides a PerlIO layer that manipulates files in the format used by the gzip program. Compression and Decompression are implemented, but not together. If you attempt to open a file for reading and writing, the open will fail. no cap, it's giving strict boundaries π
π EXPORT π
PerlIO::gzip exports no subroutines or symbols β just a perl layer gzip. that's it, that's the whole export list π«Ά
π¦ LAYER ARGUMENTS π¦
The gzip layer takes a comma separated list of arguments. 4 exclusive options choose the header checking mode:
gzip
The default. Expects a standard gzip file header for reading, writes a standard gzip file header. iconic default behavior β
none
Expects or writes no file header; assumes the file handle is immediately a deflate stream (eg as would be found inside a zip file). lowkey raw deflate mode π«§
auto
Potentially dangerous. If the first two bytes match the gzip header "\x1f\x8b" then a gzip header is assumed (and checked), else a deflate stream is assumed. No different from gzip on writing. bestie please note the danger tag π
autopop
Potentially dangerous. If the first two bytes match the gzip header "\x1f\x8b" 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.
In autopop mode, opening a handle for writing (or reading and writing) will cause the gzip layer to automatically be popped. yeah, it pops itself π
Optionally you can add this flag:
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)
By default, gzip header checking is done before the open (or binmode) returns, so if an error is detected in the gzip header the open or binmode 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 open should always succeed, but any problems with the header will cause an error on read.
open FOO, "<:gzip(lazy)", "file.gz" or die $!; # Dangerous.
while (<FOO>) {
print;
} # Whoa. Bad. You're not distinguishing between errors and EOF.
If you're not careful you won't spot the errors β like the example above, you'll think you got end of file. π
lazy is ignored if you are in autopop mode. periodt.
π AUTHOR π
Nicholas Clark, <nwc10+perlio-gzip@colon.colondot.net> π
π SEE ALSO π
perlgziprfc 1952βhttp://www.ietf.org/rfc/rfc1952.txt(the gzip file format specification)rfc 1951βhttp://www.ietf.org/rfc/rfc1951.txt(DEFLATE compressed data format specification)
mwah π this lil page is from perl v5.42.0, dated 2017-06-22, and you're reading the gzip(3) manual page. bye bestie, go compress something cute πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-PerlIO-gzip 0.20-bp160.1.13 Β· Artistic-1.0 or GPL-1.0+
- opensuse-leap 16.0: perl-PerlIO-gzip 0.20-bp160.1.13 Β· Artistic-1.0 or GPL-1.0+
- opensuse-leap 16.0: perl-PerlIO-gzip 0.20-bp160.1.13 Β· Artistic-1.0 or GPL-1.0+
- opensuse-leap 16.0: perl-PerlIO-gzip 0.20-bp160.1.13 Β· Artistic-1.0 or GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms