{
    "mode": "perldoc",
    "parameter": "IO::Compress::Zip",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ACompress%3A%3AZip/json",
    "generated": "2026-06-11T00:50:48Z",
    "synopsis": "use IO::Compress::Zip qw(zip $ZipError) ;\nmy $status = zip $input => $output [,OPTS]\nor die \"zip failed: $ZipError\\n\";\nmy $z = IO::Compress::Zip->new( $output [,OPTS] )\nor die \"zip failed: $ZipError\\n\";\n$z->print($string);\n$z->printf($format, $string);\n$z->write($string);\n$z->syswrite($string [, $length, $offset]);\n$z->flush();\n$z->tell();\n$z->eof();\n$z->seek($position, $whence);\n$z->binmode();\n$z->fileno();\n$z->opened();\n$z->autoflush();\n$z->inputlinenumber();\n$z->newStream( [OPTS] );\n$z->deflateParams();\n$z->close() ;\n$ZipError ;\n# IO::File mode\nprint $z $string;\nprintf $z $format, $string;\ntell $z\neof $z\nseek $z, $position, $whence\nbinmode $z\nfileno $z\nclose $z ;",
    "sections": {
        "NAME": {
            "content": "IO::Compress::Zip - Write zip files/buffers\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use IO::Compress::Zip qw(zip $ZipError) ;\n\nmy $status = zip $input => $output [,OPTS]\nor die \"zip failed: $ZipError\\n\";\n\nmy $z = IO::Compress::Zip->new( $output [,OPTS] )\nor die \"zip failed: $ZipError\\n\";\n\n$z->print($string);\n$z->printf($format, $string);\n$z->write($string);\n$z->syswrite($string [, $length, $offset]);\n$z->flush();\n$z->tell();\n$z->eof();\n$z->seek($position, $whence);\n$z->binmode();\n$z->fileno();\n$z->opened();\n$z->autoflush();\n$z->inputlinenumber();\n$z->newStream( [OPTS] );\n\n$z->deflateParams();\n\n$z->close() ;\n\n$ZipError ;\n\n# IO::File mode\n\nprint $z $string;\nprintf $z $format, $string;\ntell $z\neof $z\nseek $z, $position, $whence\nbinmode $z\nfileno $z\nclose $z ;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides a Perl interface that allows writing zip compressed data to files or\nbuffer.\n\nThe primary purpose of this module is to provide streaming write access to zip files and\nbuffers.\n\nAt present the following compression methods are supported by IO::Compress::Zip\n\nStore (0)\nDeflate (8)\nBzip2 (12)\nTo write Bzip2 content, the module \"IO::Uncompress::Bunzip2\" must be installed.\n\nLzma (14)\nTo write LZMA content, the module \"IO::Uncompress::UnLzma\" must be installed.\n\nZstandard (93)\nTo write Zstandard content, the module \"IO::Compress::Zstd\" must be installed.\n\nXz (95)\nTo write Xz content, the module \"IO::Uncompress::UnXz\" must be installed.\n\nFor reading zip files/buffers, see the companion module IO::Uncompress::Unzip.\n",
            "subsections": []
        },
        "Functional Interface": {
            "content": "A top-level function, \"zip\", is provided to carry out \"one-shot\" compression between buffers\nand/or files. For finer control over the compression process, see the \"OO Interface\" section.\n\nuse IO::Compress::Zip qw(zip $ZipError) ;\n\nzip $inputfilenameorreference => $outputfilenameorreference [,OPTS]\nor die \"zip failed: $ZipError\\n\";\n\nThe functional interface needs Perl5.005 or better.\n\nzip $inputfilenameorreference => $outputfilenameorreference [, OPTS]\n\"zip\" expects at least two parameters, $inputfilenameorreference and\n$outputfilenameorreference and zero or more optional parameters (see \"Optional Parameters\")\n\nThe $inputfilenameorreference parameter\nThe parameter, $inputfilenameorreference, is used to define the source of the uncompressed\ndata.\n\nIt can take one of the following forms:\n\nA filename\nIf the $inputfilenameorreference parameter is a simple scalar, it is assumed to be a\nfilename. This file will be opened for reading and the input data will be read from it.\n\nA filehandle\nIf the $inputfilenameorreference parameter is a filehandle, the input data will be read\nfrom it. The string '-' can be used as an alias for standard input.\n\nA scalar reference\nIf $inputfilenameorreference is a scalar reference, the input data will be read from\n$$inputfilenameorreference.\n\nAn array reference\nIf $inputfilenameorreference is an array reference, each element in the array must be a\nfilename.\n\nThe input data will be read from each file in turn.\n\nThe complete array will be walked to ensure that it only contains valid filenames before\nany data is compressed.\n\nAn Input FileGlob string\nIf $inputfilenameorreference is a string that is delimited by the characters \"<\" and \">\"\n\"zip\" will assume that it is an *input fileglob string*. The input is the list of files\nthat match the fileglob.\n\nSee File::GlobMapper for more details.\n\nIf the $inputfilenameorreference parameter is any other type, \"undef\" will be returned.\n\nIn addition, if $inputfilenameorreference is a simple filename, the default values for the\n\"Name\", \"Time\", \"TextFlag\", \"ExtAttr\", \"exUnixN\" and \"exTime\" options will be sourced from that\nfile.\n\nIf you do not want to use these defaults they can be overridden by explicitly setting the\n\"Name\", \"Time\", \"TextFlag\", \"ExtAttr\", \"exUnixN\" and \"exTime\" options or by setting the\n\"Minimal\" parameter.\n\nThe $outputfilenameorreference parameter\nThe parameter $outputfilenameorreference is used to control the destination of the compressed\ndata. This parameter can take one of these forms.\n\nA filename\nIf the $outputfilenameorreference parameter is a simple scalar, it is assumed to be a\nfilename. This file will be opened for writing and the compressed data will be written to\nit.\n\nA filehandle\nIf the $outputfilenameorreference parameter is a filehandle, the compressed data will be\nwritten to it. The string '-' can be used as an alias for standard output.\n\nA scalar reference\nIf $outputfilenameorreference is a scalar reference, the compressed data will be stored\nin $$outputfilenameorreference.\n\nAn Array Reference\nIf $outputfilenameorreference is an array reference, the compressed data will be pushed\nonto the array.\n\nAn Output FileGlob\nIf $outputfilenameorreference is a string that is delimited by the characters \"<\" and\n\">\" \"zip\" will assume that it is an *output fileglob string*. The output is the list of\nfiles that match the fileglob.\n\nWhen $outputfilenameorreference is an fileglob string, $inputfilenameorreference must\nalso be a fileglob string. Anything else is an error.\n\nSee File::GlobMapper for more details.\n\nIf the $outputfilenameorreference parameter is any other type, \"undef\" will be returned.\n",
            "subsections": [
                {
                    "name": "Notes",
                    "content": "When $inputfilenameorreference maps to multiple files/buffers and\n$outputfilenameorreference is a single file/buffer the input files/buffers will each be\nstored in $outputfilenameorreference as a distinct entry.\n"
                },
                {
                    "name": "Optional Parameters",
                    "content": "The optional parameters for the one-shot function \"zip\" are (for the most part) identical to\nthose used with the OO interface defined in the \"Constructor Options\" section. The exceptions\nare listed below\n\n\"AutoClose => 0|1\"\nThis option applies to any input or output data streams to \"zip\" that are filehandles.\n\nIf \"AutoClose\" is specified, and the value is true, it will result in all input and/or\noutput filehandles being closed once \"zip\" has completed.\n\nThis parameter defaults to 0.\n\n\"BinModeIn => 0|1\"\nThis option is now a no-op. All files will be read in binmode.\n\n\"Append => 0|1\"\nThe behaviour of this option is dependent on the type of output data stream.\n\n*    A Buffer\n\nIf \"Append\" is enabled, all compressed data will be append to the end of the output\nbuffer. Otherwise the output buffer will be cleared before any compressed data is\nwritten to it.\n\n*    A Filename\n\nIf \"Append\" is enabled, the file will be opened in append mode. Otherwise the contents\nof the file, if any, will be truncated before any compressed data is written to it.\n\n*    A Filehandle\n\nIf \"Append\" is enabled, the filehandle will be positioned to the end of the file via a\ncall to \"seek\" before any compressed data is written to it. Otherwise the file pointer\nwill not be moved.\n\nWhen \"Append\" is specified, and set to true, it will *append* all compressed data to the\noutput data stream.\n\nSo when the output is a filehandle it will carry out a seek to the eof before writing any\ncompressed data. If the output is a filename, it will be opened for appending. If the\noutput is a buffer, all compressed data will be appended to the existing buffer.\n\nConversely when \"Append\" is not specified, or it is present and is set to false, it will\noperate as follows.\n\nWhen the output is a filename, it will truncate the contents of the file before writing any\ncompressed data. If the output is a filehandle its position will not be changed. If the\noutput is a buffer, it will be wiped before any compressed data is output.\n\nDefaults to 0.\n"
                },
                {
                    "name": "Examples",
                    "content": "Here are a few example that show the capabilities of the module.\n\nStreaming\nThis very simple command line example demonstrates the streaming capabilities of the module. The\ncode reads data from STDIN, compresses it, and writes the compressed data to STDOUT.\n\n$ echo hello world | perl -MIO::Compress::Zip=zip -e 'zip \\*STDIN => \\*STDOUT' >output.zip\n\nThe special filename \"-\" can be used as a standin for both \"\\*STDIN\" and \"\\*STDOUT\", so the\nabove can be rewritten as\n\n$ echo hello world | perl -MIO::Compress::Zip=zip -e 'zip \"-\" => \"-\"' >output.zip\n\nOne problem with creating a zip archive directly from STDIN can be demonstrated by looking at\nthe contents of the zip file, output.zip, that we have just created.\n\n$ unzip -l output.zip\nArchive:  output.zip\nLength      Date    Time    Name\n---------  ---------- -----   ----\n12  2019-08-16 22:21\n---------                     -------\n12                     1 file\n\nThe archive member (filename) used is the empty string.\n\nIf that doesn't suit your needs, you can explicitly set the filename used in the zip archive by\nspecifying the Name option, like so\n\necho hello world | perl -MIO::Compress::Zip=zip -e 'zip \"-\" => \"-\", Name => \"hello.txt\"' >output.zip\n\nNow the contents of the zip file looks like this\n\n$ unzip -l output.zip\nArchive:  output.zip\nLength      Date    Time    Name\n---------  ---------- -----   ----\n12  2019-08-16 22:22   hello.txt\n---------                     -------\n12                     1 file\n\nCompressing a file from the filesystem\nTo read the contents of the file \"file1.txt\" and write the compressed data to the file\n\"file1.txt.zip\".\n\nuse strict ;\nuse warnings ;\nuse IO::Compress::Zip qw(zip $ZipError) ;\n\nmy $input = \"file1.txt\";\nzip $input => \"$input.zip\"\nor die \"zip failed: $ZipError\\n\";\n\nReading from a Filehandle and writing to an in-memory buffer\nTo read from an existing Perl filehandle, $input, and write the compressed data to a buffer,\n$buffer.\n\nuse strict ;\nuse warnings ;\nuse IO::Compress::Zip qw(zip $ZipError) ;\nuse IO::File ;\n\nmy $input = IO::File->new( \"<file1.txt\" )\nor die \"Cannot open 'file1.txt': $!\\n\" ;\nmy $buffer ;\nzip $input => \\$buffer\nor die \"zip failed: $ZipError\\n\";\n\nCompressing multiple files\nTo create a zip file, \"output.zip\", that contains the compressed contents of the files\n\"alpha.txt\" and \"beta.txt\"\n\nuse strict ;\nuse warnings ;\nuse IO::Compress::Zip qw(zip $ZipError) ;\n\nzip [ 'alpha.txt', 'beta.txt' ] => 'output.zip'\nor die \"zip failed: $ZipError\\n\";\n\nAlternatively, rather than having to explicitly name each of the files that you want to\ncompress, you could use a fileglob to select all the \"txt\" files in the current directory, as\nfollows\n\nuse strict ;\nuse warnings ;\nuse IO::Compress::Zip qw(zip $ZipError) ;\n\nmy @files = <*.txt>;\nzip \\@files => 'output.zip'\nor die \"zip failed: $ZipError\\n\";\n\nor more succinctly\n\nzip [ <*.txt> ] => 'output.zip'\nor die \"zip failed: $ZipError\\n\";\n\nOO Interface"
                },
                {
                    "name": "Constructor",
                    "content": "The format of the constructor for \"IO::Compress::Zip\" is shown below\n\nmy $z = IO::Compress::Zip->new( $output [,OPTS] )\nor die \"IO::Compress::Zip failed: $ZipError\\n\";\n\nIt returns an \"IO::Compress::Zip\" object on success and undef on failure. The variable $ZipError\nwill contain an error message on failure.\n\nIf you are running Perl 5.005 or better the object, $z, returned from IO::Compress::Zip can be\nused exactly like an IO::File filehandle. This means that all normal output file operations can\nbe carried out with $z. For example, to write to a compressed file/buffer you can use either of\nthese forms\n\n$z->print(\"hello world\\n\");\nprint $z \"hello world\\n\";\n\nThe mandatory parameter $output is used to control the destination of the compressed data. This\nparameter can take one of these forms.\n\nA filename\nIf the $output parameter is a simple scalar, it is assumed to be a filename. This file will\nbe opened for writing and the compressed data will be written to it.\n\nA filehandle\nIf the $output parameter is a filehandle, the compressed data will be written to it. The\nstring '-' can be used as an alias for standard output.\n\nA scalar reference\nIf $output is a scalar reference, the compressed data will be stored in $$output.\n\nIf the $output parameter is any other type, \"IO::Compress::Zip\"::new will return undef.\n"
                },
                {
                    "name": "Constructor Options",
                    "content": "\"OPTS\" is any combination of zero or more the following options:\n\n\"AutoClose => 0|1\"\nThis option is only valid when the $output parameter is a filehandle. If specified, and the\nvalue is true, it will result in the $output being closed once either the \"close\" method is\ncalled or the \"IO::Compress::Zip\" object is destroyed.\n\nThis parameter defaults to 0.\n\n\"Append => 0|1\"\nOpens $output in append mode.\n\nThe behaviour of this option is dependent on the type of $output.\n\n*    A Buffer\n\nIf $output is a buffer and \"Append\" is enabled, all compressed data will be append to\nthe end of $output. Otherwise $output will be cleared before any data is written to\nit.\n\n*    A Filename\n\nIf $output is a filename and \"Append\" is enabled, the file will be opened in append\nmode. Otherwise the contents of the file, if any, will be truncated before any\ncompressed data is written to it.\n\n*    A Filehandle\n\nIf $output is a filehandle, the file pointer will be positioned to the end of the file\nvia a call to \"seek\" before any compressed data is written to it. Otherwise the file\npointer will not be moved.\n\nThis parameter defaults to 0.\n\nFile Naming Options\nA quick bit of zip file terminology -- A zip archive consists of one or more *archive members*,\nwhere each member has an associated filename, known as the *archive member name*.\n\nThe options listed in this section control how the *archive member name* (or filename) is stored\nthe zip archive.\n\n\"Name => $string\"\nThis option is used to explicitly set the *archive member name* in the zip archive to\n$string. Most of the time you don't need to make use of this option. By default when adding\na filename to the zip archive, the *archive member name* will match the filename.\n\nYou should only need to use this option if you want the *archive member name* to be\ndifferent from the uncompressed filename or when the input is a filehandle or a buffer.\n\nThe default behaviour for what *archive member name* is used when the \"Name\" option is\n*not* specified depends on the form of the $input parameter:\n\n*    If the $input parameter is a filename, the value of $input will be used for the\n*archive member name* .\n\n*    If the $input parameter is not a filename, the *archive member name* will be an empty\nstring.\n\nNote that both the \"CanonicalName\" and \"FilterName\" options can modify the value used for\nthe *archive member name*.\n\nAlso note that you should set the \"Efs\" option to true if you are working with UTF8\nfilenames.\n\n\"CanonicalName => 0|1\"\nThis option controls whether the *archive member name* is *normalized* into Unix format\nbefore being written to the zip file.\n\nIt is recommended that you enable this option unless you really need to create a\nnon-standard Zip file.\n\nThis is what APPNOTE.TXT has to say on what should be stored in the zip filename header\nfield.\n\nThe name of the file, with optional relative path.\nThe path stored should not contain a drive or\ndevice letter, or a leading slash.  All slashes\nshould be forward slashes '/' as opposed to\nbackwards slashes '\\' for compatibility with Amiga\nand UNIX file systems etc.\n\nThis option defaults to false.\n\n\"FilterName => sub { ... }\"\nThis option allow the *archive member* name to be modified before it is written to the zip\nfile.\n\nThis option takes a parameter that must be a reference to a sub. On entry to the sub the $\nvariable will contain the name to be filtered. If no filename is available $ will contain\nan empty string.\n\nThe value of $ when the sub returns will be used as the *archive member name*.\n\nNote that if \"CanonicalName\" is enabled, a normalized filename will be passed to the sub.\n\nIf you use \"FilterName\" to modify the filename, it is your responsibility to keep the\nfilename in Unix format.\n\nAlthough this option can be used with the OO interface, it is of most use with the one-shot\ninterface. For example, the code below shows how \"FilterName\" can be used to remove the\npath component from a series of filenames before they are stored in $zipfile.\n\nsub compressTxtFiles\n{\nmy $zipfile = shift ;\nmy $dir     = shift ;\n\nzip [ <$dir/*.txt> ] => $zipfile,\nFilterName => sub { s[^$dir/][] } ;\n}\n\n\"Efs => 0|1\"\nThis option controls setting of the \"Language Encoding Flag\" (EFS) in the zip archive. When\nset, the filename and comment fields for the zip archive MUST be valid UTF-8.\n\nIf the string used for the filename and/or comment is not valid UTF-8 when this option is\ntrue, the script will die with a \"wide character\" error.\n\nNote that this option only works with Perl 5.8.4 or better.\n\nThis option defaults to false.\n\nOverall Zip Archive Structure\n\"Minimal => 1|0\"\nIf specified, this option will disable the creation of all extra fields in the zip local\nand central headers. So the \"exTime\", \"exUnix2\", \"exUnixN\", \"ExtraFieldLocal\" and\n\"ExtraFieldCentral\" options will be ignored.\n\nThis parameter defaults to 0.\n\n\"Stream => 0|1\"\nThis option controls whether the zip file/buffer output is created in streaming mode.\n\nNote that when outputting to a file with streaming mode disabled (\"Stream\" is 0), the\noutput file must be seekable.\n\nThe default is 1.\n\n\"Zip64 => 0|1\"\nCreate a Zip64 zip file/buffer. This option is used if you want to store files larger than\n4 Gig or store more than 64K files in a single zip archive.\n\n\"Zip64\" will be automatically set, as needed, if working with the one-shot interface when\nthe input is either a filename or a scalar reference.\n\nIf you intend to manipulate the Zip64 zip files created with this module using an external\nzip/unzip, make sure that it supports Zip64.\n\nIn particular, if you are using Info-Zip you need to have zip version 3.x or better to\nupdate a Zip64 archive and unzip version 6.x to read a zip64 archive.\n\nThe default is 0.\n\nDeflate Compression Options"
                },
                {
                    "name": "-Level",
                    "content": "Defines the compression level used by zlib. The value should either be a number between 0\nand 9 (0 means no compression and 9 is maximum compression), or one of the symbolic\nconstants defined below.\n\nZNOCOMPRESSION\nZBESTSPEED\nZBESTCOMPRESSION\nZDEFAULTCOMPRESSION\n\nThe default is ZDEFAULTCOMPRESSION.\n\nNote, these constants are not imported by \"IO::Compress::Zip\" by default.\n\nuse IO::Compress::Zip qw(:strategy);\nuse IO::Compress::Zip qw(:constants);\nuse IO::Compress::Zip qw(:all);\n"
                },
                {
                    "name": "-Strategy",
                    "content": "Defines the strategy used to tune the compression. Use one of the symbolic constants\ndefined below.\n\nZFILTERED\nZHUFFMANONLY\nZRLE\nZFIXED\nZDEFAULTSTRATEGY\n\nThe default is ZDEFAULTSTRATEGY.\n\nBzip2 Compression Options\n\"BlockSize100K => number\"\nSpecify the number of 100K blocks bzip2 uses during compression.\n\nValid values are from 1 to 9, where 9 is best compression.\n\nThis option is only valid if the \"Method\" is ZIPCMBZIP2. It is ignored otherwise.\n\nThe default is 1.\n\n\"WorkFactor => number\"\nSpecifies how much effort bzip2 should take before resorting to a slower fallback\ncompression algorithm.\n\nValid values range from 0 to 250, where 0 means use the default value 30.\n\nThis option is only valid if the \"Method\" is ZIPCMBZIP2. It is ignored otherwise.\n\nThe default is 0.\n\nLzma and Xz Compression Options\n\"Preset => number\"\nUsed to choose the LZMA compression preset.\n\nValid values are 0-9 and \"LZMAPRESETDEFAULT\".\n\n0 is the fastest compression with the lowest memory usage and the lowest compression.\n\n9 is the slowest compression with the highest memory usage but with the best compression.\n\nThis option is only valid if the \"Method\" is ZIPCMLZMA. It is ignored otherwise.\n\nDefaults to \"LZMAPRESETDEFAULT\" (6).\n\n\"Extreme => 0|1\"\nMakes LZMA compression a lot slower, but a small compression gain.\n\nThis option is only valid if the \"Method\" is ZIPCMLZMA. It is ignored otherwise.\n\nDefaults to 0.\n\nOther Options\n\"Time => $number\"\nSets the last modified time field in the zip header to $number.\n\nThis field defaults to the time the \"IO::Compress::Zip\" object was created if this option\nis not specified and the $input parameter is not a filename.\n\n\"ExtAttr => $attr\"\nThis option controls the \"external file attributes\" field in the central header of the zip\nfile. This is a 4 byte field.\n\nIf you are running a Unix derivative this value defaults to\n\n0100644 << 16\n\nThis should allow read/write access to any files that are extracted from the zip\nfile/buffer`.\n\nFor all other systems it defaults to 0.\n\n\"exTime => [$atime, $mtime, $ctime]\"\nThis option expects an array reference with exactly three elements: $atime, \"mtime\" and\n$ctime. These correspond to the last access time, last modification time and creation time\nrespectively.\n\nIt uses these values to set the extended timestamp field (ID is \"UT\") in the local zip\nheader using the three values, $atime, $mtime, $ctime. In addition it sets the extended\ntimestamp field in the central zip header using $mtime.\n\nIf any of the three values is \"undef\" that time value will not be used. So, for example, to\nset only the $mtime you would use this\n\nexTime => [undef, $mtime, undef]\n\nIf the \"Minimal\" option is set to true, this option will be ignored.\n\nBy default no extended time field is created.\n\n\"exUnix2 => [$uid, $gid]\"\nThis option expects an array reference with exactly two elements: $uid and $gid. These\nvalues correspond to the numeric User ID (UID) and Group ID (GID) of the owner of the files\nrespectively.\n\nWhen the \"exUnix2\" option is present it will trigger the creation of a Unix2 extra field\n(ID is \"Ux\") in the local zip header. This will be populated with $uid and $gid. An empty\nUnix2 extra field will also be created in the central zip header.\n\nNote - The UID & GID are stored as 16-bit integers in the \"Ux\" field. Use \"exUnixN\" if your\nUID or GID are 32-bit.\n\nIf the \"Minimal\" option is set to true, this option will be ignored.\n\nBy default no Unix2 extra field is created.\n\n\"exUnixN => [$uid, $gid]\"\nThis option expects an array reference with exactly two elements: $uid and $gid. These\nvalues correspond to the numeric User ID (UID) and Group ID (GID) of the owner of the files\nrespectively.\n\nWhen the \"exUnixN\" option is present it will trigger the creation of a UnixN extra field\n(ID is \"ux\") in both the local and central zip headers. This will be populated with $uid\nand $gid. The UID & GID are stored as 32-bit integers.\n\nIf the \"Minimal\" option is set to true, this option will be ignored.\n\nBy default no UnixN extra field is created.\n\n\"Comment => $comment\"\nStores the contents of $comment in the Central File Header of the zip file.\n\nSet the \"Efs\" option to true if you want to store a UTF8 comment.\n\nBy default, no comment field is written to the zip file.\n\n\"ZipComment => $comment\"\nStores the contents of $comment in the End of Central Directory record of the zip file.\n\nBy default, no comment field is written to the zip file.\n\n\"Method => $method\"\nControls which compression method is used. At present the compression methods supported\nare: Store (no compression at all), Deflate, Bzip2, Zstd, Xz and Lzma.\n\nThe symbols ZIPCMSTORE, ZIPCMDEFLATE, ZIPCMBZIP2, ZIPCMZSTD, ZIPCMXZ and\nZIPCMLZMA are used to select the compression method.\n\nThese constants are not imported by \"IO::Compress::Zip\" by default.\n\nuse IO::Compress::Zip qw(:zipmethod);\nuse IO::Compress::Zip qw(:constants);\nuse IO::Compress::Zip qw(:all);\n\nNote that to create Bzip2 content, the module \"IO::Compress::Bzip2\" must be installed. A\nfatal error will be thrown if you attempt to create Bzip2 content when\n\"IO::Compress::Bzip2\" is not available.\n\nNote that to create Lzma content, the module \"IO::Compress::Lzma\" must be installed. A\nfatal error will be thrown if you attempt to create Lzma content when \"IO::Compress::Lzma\"\nis not available.\n\nNote that to create Xz content, the module \"IO::Compress::Xz\" must be installed. A fatal\nerror will be thrown if you attempt to create Xz content when \"IO::Compress::Xz\" is not\navailable.\n\nNote that to create Zstd content, the module \"IO::Compress::Zstd\" must be installed. A\nfatal error will be thrown if you attempt to create Zstd content when \"IO::Compress::Zstd\"\nis not available.\n\nThe default method is ZIPCMDEFLATE.\n\n\"TextFlag => 0|1\"\nThis parameter controls the setting of a bit in the zip central header. It is used to\nsignal that the data stored in the zip file/buffer is probably text.\n\nIn one-shot mode this flag will be set to true if the Perl \"-T\" operator thinks the file\ncontains text.\n\nThe default is 0.\n\n\"ExtraFieldLocal => $data\"\n\"ExtraFieldCentral => $data\"\nThe \"ExtraFieldLocal\" option is used to store additional metadata in the local header for\nthe zip file/buffer. The \"ExtraFieldCentral\" does the same for the matching central header.\n\nAn extra field consists of zero or more subfields. Each subfield consists of a two byte\nheader followed by the subfield data.\n\nThe list of subfields can be supplied in any of the following formats\n\nExtraFieldLocal => [$id1, $data1,\n$id2, $data2,\n...\n]\n\nExtraFieldLocal => [ [$id1 => $data1],\n[$id2 => $data2],\n...\n]\n\nExtraFieldLocal => { $id1 => $data1,\n$id2 => $data2,\n...\n}\n\nWhere $id1, $id2 are two byte subfield ID's.\n\nIf you use the hash syntax, you have no control over the order in which the ExtraSubFields\nare stored, plus you cannot have SubFields with duplicate ID.\n\nAlternatively the list of subfields can by supplied as a scalar, thus\n\nExtraField => $rawdata\n\nIn this case \"IO::Compress::Zip\" will check that $rawdata consists of zero or more\nconformant sub-fields.\n\nThe Extended Time field (ID \"UT\"), set using the \"exTime\" option, and the Unix2 extra field\n(ID \"Ux), set using the \"exUnix2\" option, are examples of extra fields.\n\nIf the \"Minimal\" option is set to true, this option will be ignored.\n\nThe maximum size of an extra field 65535 bytes.\n\n\"Strict => 0|1\"\nThis is a placeholder option.\n"
                },
                {
                    "name": "Examples",
                    "content": "TODO\n"
                }
            ]
        },
        "Methods": {
            "content": "print\nUsage is\n\n$z->print($data)\nprint $z $data\n\nCompresses and outputs the contents of the $data parameter. This has the same behaviour as the\n\"print\" built-in.\n\nReturns true if successful.\n\nprintf\nUsage is\n\n$z->printf($format, $data)\nprintf $z $format, $data\n\nCompresses and outputs the contents of the $data parameter.\n\nReturns true if successful.\n\nsyswrite\nUsage is\n\n$z->syswrite $data\n$z->syswrite $data, $length\n$z->syswrite $data, $length, $offset\n\nCompresses and outputs the contents of the $data parameter.\n\nReturns the number of uncompressed bytes written, or \"undef\" if unsuccessful.\n\nwrite\nUsage is\n\n$z->write $data\n$z->write $data, $length\n$z->write $data, $length, $offset\n\nCompresses and outputs the contents of the $data parameter.\n\nReturns the number of uncompressed bytes written, or \"undef\" if unsuccessful.\n\nflush\nUsage is\n\n$z->flush;\n$z->flush($flushtype);\n\nFlushes any pending compressed data to the output file/buffer.\n\nThis method takes an optional parameter, $flushtype, that controls how the flushing will be\ncarried out. By default the $flushtype used is \"ZFINISH\". Other valid values for $flushtype\nare \"ZNOFLUSH\", \"ZSYNCFLUSH\", \"ZFULLFLUSH\" and \"ZBLOCK\". It is strongly recommended that\nyou only set the \"flushtype\" parameter if you fully understand the implications of what it does\n- overuse of \"flush\" can seriously degrade the level of compression achieved. See the \"zlib\"\ndocumentation for details.\n\nReturns true on success.\n\ntell\nUsage is\n\n$z->tell()\ntell $z\n\nReturns the uncompressed file offset.\n\neof\nUsage is\n\n$z->eof();\neof($z);\n\nReturns true if the \"close\" method has been called.\n\nseek\n$z->seek($position, $whence);\nseek($z, $position, $whence);\n\nProvides a sub-set of the \"seek\" functionality, with the restriction that it is only legal to\nseek forward in the output file/buffer. It is a fatal error to attempt to seek backward.\n\nEmpty parts of the file/buffer will have NULL (0x00) bytes written to them.\n\nThe $whence parameter takes one the usual values, namely SEEKSET, SEEKCUR or SEEKEND.\n\nReturns 1 on success, 0 on failure.\n\nbinmode\nUsage is\n\n$z->binmode\nbinmode $z ;\n\nThis is a noop provided for completeness.\n\nopened\n$z->opened()\n\nReturns true if the object currently refers to a opened file/buffer.\n\nautoflush\nmy $prev = $z->autoflush()\nmy $prev = $z->autoflush(EXPR)\n\nIf the $z object is associated with a file or a filehandle, this method returns the current\nautoflush setting for the underlying filehandle. If \"EXPR\" is present, and is non-zero, it will\nenable flushing after every write/print operation.\n\nIf $z is associated with a buffer, this method has no effect and always returns \"undef\".\n\nNote that the special variable $| cannot be used to set or retrieve the autoflush setting.\n\ninputlinenumber\n$z->inputlinenumber()\n$z->inputlinenumber(EXPR)\n\nThis method always returns \"undef\" when compressing.\n\nfileno\n$z->fileno()\nfileno($z)\n\nIf the $z object is associated with a file or a filehandle, \"fileno\" will return the underlying\nfile descriptor. Once the \"close\" method is called \"fileno\" will return \"undef\".\n\nIf the $z object is associated with a buffer, this method will return \"undef\".\n\nclose\n$z->close() ;\nclose $z ;\n\nFlushes any pending compressed data and then closes the output file/buffer.\n\nFor most versions of Perl this method will be automatically invoked if the IO::Compress::Zip\nobject is destroyed (either explicitly or by the variable with the reference to the object going\nout of scope). The exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In these cases,\nthe \"close\" method will be called automatically, but not until global destruction of all live\nobjects when the program is terminating.\n\nTherefore, if you want your scripts to be able to run on all versions of Perl, you should call\n\"close\" explicitly and not rely on automatic closing.\n\nReturns true on success, otherwise 0.\n\nIf the \"AutoClose\" option has been enabled when the IO::Compress::Zip object was created, and\nthe object is associated with a file, the underlying file will also be closed.\n\nnewStream([OPTS])\nUsage is\n\n$z->newStream( [OPTS] )\n\nCloses the current compressed data stream and starts a new one.\n\nOPTS consists of any of the options that are available when creating the $z object.\n\nSee the \"Constructor Options\" section for more details.\n\ndeflateParams\nUsage is\n\n$z->deflateParams\n\nTODO\n",
            "subsections": []
        },
        "Importing": {
            "content": "A number of symbolic constants are required by some methods in \"IO::Compress::Zip\". None are\nimported by default.\n\n:all Imports \"zip\", $ZipError and all symbolic constants that can be used by\n\"IO::Compress::Zip\". Same as doing this\n\nuse IO::Compress::Zip qw(zip $ZipError :constants) ;\n\n:constants\nImport all symbolic constants. Same as doing this\n\nuse IO::Compress::Zip qw(:flush :level :strategy :zipmethod) ;\n\n:flush\nThese symbolic constants are used by the \"flush\" method.\n\nZNOFLUSH\nZPARTIALFLUSH\nZSYNCFLUSH\nZFULLFLUSH\nZFINISH\nZBLOCK\n\n:level\nThese symbolic constants are used by the \"Level\" option in the constructor.\n\nZNOCOMPRESSION\nZBESTSPEED\nZBESTCOMPRESSION\nZDEFAULTCOMPRESSION\n\n:strategy\nThese symbolic constants are used by the \"Strategy\" option in the constructor.\n\nZFILTERED\nZHUFFMANONLY\nZRLE\nZFIXED\nZDEFAULTSTRATEGY\n\n:zipmethod\nThese symbolic constants are used by the \"Method\" option in the constructor.\n\nZIPCMSTORE\nZIPCMDEFLATE\nZIPCMBZIP2\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "",
            "subsections": [
                {
                    "name": "Apache::GZip Revisited",
                    "content": "See IO::Compress::FAQ\n"
                },
                {
                    "name": "Working with Net::FTP",
                    "content": "See IO::Compress::FAQ\n"
                }
            ]
        },
        "SUPPORT": {
            "content": "General feedback/questions/bug reports should be sent to\n<https://github.com/pmqs/IO-Compress/issues> (preferred) or\n<https://rt.cpan.org/Public/Dist/Display.html?Name=IO-Compress>.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip, IO::Compress::Deflate,\nIO::Uncompress::Inflate, IO::Compress::RawDeflate, IO::Uncompress::RawInflate,\nIO::Compress::Bzip2, IO::Uncompress::Bunzip2, IO::Compress::Lzma, IO::Uncompress::UnLzma,\nIO::Compress::Xz, IO::Uncompress::UnXz, IO::Compress::Lzip, IO::Uncompress::UnLzip,\nIO::Compress::Lzop, IO::Uncompress::UnLzop, IO::Compress::Lzf, IO::Uncompress::UnLzf,\nIO::Compress::Zstd, IO::Uncompress::UnZstd, IO::Uncompress::AnyInflate,\nIO::Uncompress::AnyUncompress\n\nIO::Compress::FAQ\n\nFile::GlobMapper, Archive::Zip, Archive::Tar, IO::Zlib\n\nFor RFC 1950, 1951 and 1952 see <http://www.faqs.org/rfcs/rfc1950.html>,\n<http://www.faqs.org/rfcs/rfc1951.html> and <http://www.faqs.org/rfcs/rfc1952.html>\n\nThe *zlib* compression library was written by Jean-loup Gailly \"gzip@prep.ai.mit.edu\" and Mark\nAdler \"madler@alumni.caltech.edu\".\n\nThe primary site for the *zlib* compression library is <http://www.zlib.org>.\n\nThe primary site for gzip is <http://www.gzip.org>.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "This module was written by Paul Marquess, \"pmqs@cpan.org\".\n",
            "subsections": []
        },
        "MODIFICATION HISTORY": {
            "content": "See the Changes file.\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "Copyright (c) 2005-2021 Paul Marquess. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        }
    },
    "summary": "IO::Compress::Zip - Write zip files/buffers",
    "flags": [],
    "examples": [
        "See IO::Compress::FAQ",
        "See IO::Compress::FAQ"
    ],
    "see_also": []
}