Archive::Zip(3)

✨ NAME ✨

Okay bestie, welcome to Archive::Zip(3) β€” yes, from the User Contributed Perl Documentation β€” and it literally gives you an interface to ZIP archive files. That’s the vibe. 🫢

πŸš€ SYNOPSIS πŸš€

Here’s the group-chat recap of what this looks like in action β€” code is exact, copy away:

# Create a Zip file
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
my $zip = Archive::Zip->new();

# Add a directory
my $dir_member = $zip->addDirectory( 'dirname/' );

# Add a file from a string with compression
my $string_member = $zip->addString( 'This is a test', 'stringMember.txt' );
$string_member->desiredCompressionMethod( COMPRESSION_DEFLATED );

# Add a file from disk
my $file_member = $zip->addFile( 'xyz.pl', 'AnotherName.pl' );

# Save the Zip file
unless ( $zip->writeToFileNamed('someZip.zip') == AZ_OK ) {
    die 'write error';
}

# Read a Zip file
my $somezip = Archive::Zip->new();
unless ( $somezip->read( 'someZip.zip' ) == AZ_OK ) {
    die 'read error';
}

# Change the compression type for a file in the Zip
my $member = $somezip->memberNamed( 'stringMember.txt' );
$member->desiredCompressionMethod( COMPRESSION_STORED );
unless ( $zip->writeToFileNamed( 'someOtherZip.zip' ) == AZ_OK ) {
    die 'write error';
}

πŸ’– DESCRIPTION πŸ’–

Archive::Zip is the module that lets a Perl program create, manipulate, read, and write Zip archive files. Zip archives can be created, or you can read from existing zip files. Once created, they can be written to files, streams, or strings. Members can be added, removed, extracted, replaced, rearranged, and enumerated. They can also be renamed or have their dates, comments, or other attributes queried or modified. Their data can be compressed or uncompressed as needed. πŸ“¦βœ¨

Members can be created from members in existing Zip files, or from existing directories, files, or strings.

This module uses the Compress::Raw::Zlib library to read and write the compressed streams inside the files.

One can use Archive::Zip::MemberRead to read the zip file archive members as if they were files.

πŸ“ File Naming πŸ“

Okay so here’s the naming tea: regardless of what your local file system uses for file naming, names in a Zip file are in Unix format (forward slashes (/) separating directory names, etc.).

Archive::Zip tries to be consistent with file naming conventions, and will translate back and forth between native and Zip file names.

However, it can’t guess which format names are in. So two rules control what kind of file name you must pass various routines:

  • Names of files are in local format. File::Spec and File::Basename are used for various file operations. When you’re referring to a file on your system, use its file naming conventions.
  • Names of archive members are in Unix format. This applies to every method that refers to an archive member, or provides a name for new archive members. The extract() methods that can take one or two names will convert from local to zip names if you call them with a single name.

🧸 Archive::Zip Object Model 🧸

πŸ‘€ Overview πŸ‘€

Archive::Zip::Archive objects are what you ordinarily deal with. These maintain the structure of a zip file, without necessarily holding data. When a zip is read from a disk file, the (possibly compressed) data still lives in the file, not in memory. Archive members hold information about the individual members, but not (usually) the actual member data. When the zip is written to a (different) file, the member data is compressed or copied as needed. It is possible to make archive members whose data is held in a string in memory, but this is not done when a zip file is read. Directory members don’t have any data. πŸ’…

🌳 Inheritance 🌳

Like, the whole family tree is giving legacy:

  Exporter
   Archive::Zip                            Common base class, has defs.
       Archive::Zip::Archive               A Zip archive.
       Archive::Zip::Member                Abstract superclass for all members.
           Archive::Zip::StringMember      Member made from a string
           Archive::Zip::FileMember        Member made from an external file
               Archive::Zip::ZipFileMember Member that lives in a zip file
               Archive::Zip::NewFileMember Member whose data is in a file
           Archive::Zip::DirectoryMember   Member that is a directory

🎁 EXPORTS 🎁

:CONSTANTS

Exports the following constants:

FA_MSDOS FA_UNIX GPBF_ENCRYPTED_MASK GPBF_DEFLATING_COMPRESSION_MASK
GPBF_HAS_DATA_DESCRIPTOR_MASK COMPRESSION_STORED
COMPRESSION_DEFLATED IFA_TEXT_FILE_MASK IFA_TEXT_FILE
IFA_BINARY_FILE COMPRESSION_LEVEL_NONE COMPRESSION_LEVEL_DEFAULT
COMPRESSION_LEVEL_FASTEST COMPRESSION_LEVEL_BEST_COMPRESSION
ZIP64_SUPPORTED ZIP64_AS_NEEDED ZIP64_EOCD ZIP64_HEADERS

:MISC_CONSTANTS

Exports the following constants (only necessary for extending the module):

FA_AMIGA FA_VAX_VMS FA_VM_CMS FA_ATARI_ST FA_OS2_HPFS FA_MACINTOSH
FA_Z_SYSTEM FA_CPM FA_WINDOWS_NTFS
GPBF_IMPLODING_8K_SLIDING_DICTIONARY_MASK
GPBF_IMPLODING_3_SHANNON_FANO_TREES_MASK
GPBF_IS_COMPRESSED_PATCHED_DATA_MASK COMPRESSION_SHRUNK
DEFLATING_COMPRESSION_NORMAL DEFLATING_COMPRESSION_MAXIMUM
DEFLATING_COMPRESSION_FAST DEFLATING_COMPRESSION_SUPER_FAST
COMPRESSION_REDUCED_1 COMPRESSION_REDUCED_2 COMPRESSION_REDUCED_3
COMPRESSION_REDUCED_4 COMPRESSION_IMPLODED COMPRESSION_TOKENIZED
COMPRESSION_DEFLATED_ENHANCED
COMPRESSION_PKWARE_DATA_COMPRESSION_LIBRARY_IMPLODED

:ERROR_CODES

Explained below. Returned from most methods.

AZ_OK AZ_STREAM_END AZ_ERROR AZ_FORMAT_ERROR AZ_IO_ERROR

⚠️ ERROR CODES ⚠️

Many of the methods in Archive::Zip return error codes. These are implemented as inline subroutines, using the use constant pragma. They can be imported into your namespace using the :ERROR_CODES tag:

use Archive::Zip qw( :ERROR_CODES );

...

unless ( $zip->read( 'myfile.zip' ) == AZ_OK ) {
    die "whoops!";
}
  • AZ_OK (0) β€” Everything is fine.
  • AZ_STREAM_END (1) β€” The read stream (or central directory) ended normally.
  • AZ_ERROR (2) β€” There was some generic kind of error.
  • AZ_FORMAT_ERROR (3) β€” There is a format error in a ZIP file being read.
  • AZ_IO_ERROR (4) β€” There was an IO error.

πŸ—œοΈ Compression πŸ—œοΈ

Archive::Zip allows each member of a ZIP file to be compressed (using the Deflate algorithm) or uncompressed.

Other compression algorithms that some versions of ZIP have been able to produce are not supported. Each member has two compression methods: the one it’s stored as (this is always COMPRESSION_STORED for string and external file members), and the one you desire for the member in the zip file.

These can be different, of course, so you can make a zip member that is not compressed out of one that is, and vice versa.

You can inquire about the current compression and set the desired compression method:

my $member = $zip->memberNamed( 'xyz.txt' );
$member->compressionMethod();    # return current compression

# set to read uncompressed
$member->desiredCompressionMethod( COMPRESSION_STORED );

# set to read compressed
$member->desiredCompressionMethod( COMPRESSION_DEFLATED );

There are two different compression methods:

  • COMPRESSION_STORED β€” File is stored (no compression)
  • COMPRESSION_DEFLATED β€” File is Deflated

🎚️ Compression Levels 🎚️

If a member’s desiredCompressionMethod is COMPRESSION_DEFLATED, you can choose different compression levels. This choice may affect the speed of compression and decompression, as well as the size of the compressed member data.

$member->desiredCompressionLevel( 9 );

The levels given can be:

  • 0 or COMPRESSION_LEVEL_NONE β€” This is the same as saying
$member->desiredCompressionMethod( COMPRESSION_STORED );
  • 1 .. 9 β€” 1 gives the best speed and worst compression, and 9 gives the best compression and worst speed.
  • COMPRESSION_LEVEL_FASTEST β€” This is a synonym for level 1.
  • COMPRESSION_LEVEL_BEST_COMPRESSION β€” This is a synonym for level 9.
  • COMPRESSION_LEVEL_DEFAULT β€” This gives a good compromise between speed and compression, and is currently equivalent to 6 (this is in the zlib code). This is the level that will be used if not specified.

πŸ› οΈ Archive::Zip Methods πŸ› οΈ

The Archive::Zip class (and its invisible subclass Archive::Zip::Archive) implement generic zip file functionality. Creating a new Archive::Zip object actually makes an Archive::Zip::Archive object, but you don’t have to worry about this unless you’re subclassing.

🐣 Constructor 🐣

new( [$fileName] )
new( { filename => $fileName } )

Make a new, empty zip archive.

my $zip = Archive::Zip->new();

If an additional argument is passed, new() will call read() to read the contents of an archive:

my $zip = Archive::Zip->new( 'xyz.zip' );

If a filename argument is passed and the read fails for any reason, new will return undef. For this reason, it may be better to call read separately.

🧰 Zip Archive Utility Methods 🧰

These Archive::Zip methods may be called as functions or as object methods. Do not call them as class methods:

$zip = Archive::Zip->new();
$crc = Archive::Zip::computeCRC32( 'ghijkl' );    # OK
$crc = $zip->computeCRC32( 'ghijkl' );            # also OK
$crc = Archive::Zip->computeCRC32( 'ghijkl' );    # NOT OK
Archive::Zip::computeCRC32( $string [, $crc] )
Archive::Zip::computeCRC32( { string => $string [, checksum => $crc ] } )

This is a utility function that uses the Compress::Raw::Zlib CRC routine to compute a CRC-32. You can get the CRC of a string:

$crc = Archive::Zip::computeCRC32( $string );

Or you can compute the running CRC:

$crc = 0;
$crc = Archive::Zip::computeCRC32( 'abcdef', $crc );
$crc = Archive::Zip::computeCRC32( 'ghijkl', $crc );
Archive::Zip::setChunkSize( $number )
Archive::Zip::setChunkSize( { chunkSize => $number } )

Report or change chunk size used for reading and writing. This can make big differences in dealing with large files. Currently, this defaults to 32K. This also changes the chunk size used for Compress::Raw::Zlib. You must call setChunkSize() before reading or writing. This is not exportable, so you must call it like:

Archive::Zip::setChunkSize( 4096 );

or as a method on a zip (though this is a global setting). Returns old chunk size.

Archive::Zip::chunkSize()

Returns the current chunk size:

my $chunkSize = Archive::Zip::chunkSize();

Archive::Zip::setErrorHandler( \&subroutine )

Swap out the sub that gets called whenever an error string shows up ✨ it defaults to \&Carp::carp, but bestie you probably wanna change it so you can actually get those error strings. Heads up: this one is not exportable, so you gotta call it the long way:

Archive::Zip::setErrorHandler( \&myErrorHandler );

If myErrorHandler is undef, it resets the handler back to default. Returns the old error handler 🫢

Ok so real talk β€” if you call Carp::carp or something similar, or if you're chaining to the default error handler from inside your own error handler, you may wanna bump up the number of caller levels that get skipped (and like, do not just set it to a number, ok?):
$Carp::CarpLevel++;

Archive::Zip::tempFile( [ $tmpdir ] )

Archive::Zip::tempFile( { tempDir => $tmpdir } )

Makes a uniquely-named temp file for you, and hands it back already open for read/write πŸ‘‘

If $tmpdir is given, that's the directory name it'll create the file in. If you don't pass one, it creates the file using File::Spec::tmpdir(). Generally you can override that choice with the:

$ENV{TMPDIR}

environment variable. But fr fr, go read the File::Spec documentation for your system. Also note: on a lot of systems, if you're running in taint mode, you gotta make sure $ENV{TMPDIR} is untainted before it'll get used πŸ™ˆ

⚠️ It will NOT create $tmpdir if it doesn't already exist β€” and yes, that's a change from prior versions!

Returns the file handle and the name:

my ($fh, $name) = Archive::Zip::tempFile();
my ($fh, $name) = Archive::Zip::tempFile('myTempDir');
my $fh = Archive::Zip::tempFile();  # if you don't need the name

πŸ¦‹ Zip Archive Accessors πŸ¦‹

members()

Returns a copy of the members array πŸ’…

my @members = $zip->members();

numberOfMembers()

Returns how many members I have. Periodt.

memberNames()

Returns a list of the (internal) file names of the zip members ✨

memberNamed( $string )

memberNamed( { zipName => $string } )

Returns a ref to the member whose filename equals the given filename, or undef if there isn't one. $string has to be in Zip (Unix) filename format, no cap.

membersMatching( $regex )

membersMatching( { regex => $regex } )

Returns an array of the members whose filenames match the given regular expression β€” but only in list context. In scalar context it returns the number of matching members πŸ”₯

my @textFileMembers = $zip->membersMatching( '.*\.txt' );
# or
my $numberOfTextFiles = $zip->membersMatching( '.*\.txt' );

zip64()

Tells you whether the previous read or write of the archive was done in zip64 format πŸ‘‘

desiredZip64Mode()

Gets or sets which parts of the archive should be written in zip64 format:

  • ZIP64_AS_NEEDED β€” all parts as needed. This is the default 🌈
  • ZIP64_EOCD β€” force writing the zip64 end of central directory record
  • ZIP64_HEADERS β€” force writing the zip64 EOCD record and all headers in zip64 format

versionMadeBy()

versionNeededToExtract()

Gets those fields from the zip64 end of central directory record. These are always 0 if the archive isn't in zip64 format πŸ’€

diskNumber()

Returns the disk I start on. Not used for writing zips, but it might be interesting if you read a zip in πŸ‘€ This should be 0, since Archive::Zip does not handle multi-volume archives.

diskNumberWithStartOfCentralDirectory()

Returns the disk number that holds the beginning of the central directory. Again, not used for writing zips, but could be a fun little read-in fact. Should be 0 β€” Archive::Zip does not handle multi-volume archives, bestie.

numberOfCentralDirectoriesOnThisDisk()

Returns the number of CD structures in the zipfile last read in. Not used for writing zips, but might be interesting if you read a zip in ✨

numberOfCentralDirectories()

Returns the number of CD structures in the zipfile last read in. Not used for writing zips, but might be interesting if you read a zip in ✨

centralDirectorySize()

Returns the central directory size, as read from an external zip file. Not used for writing zips, but might be interesting if you read a zip in πŸŽ€

centralDirectoryOffsetWRTStartingDiskNumber()

Returns the offset into the zip file where the CD begins. Not used for writing zips, but might be interesting if you read a zip in πŸŽ€

zipfileComment( [ $string ] )

zipfileComment( [ { comment => $string } ] )

Get or set the zipfile comment πŸ’¬ Returns the old comment.

print $zip->zipfileComment();
$zip->zipfileComment( 'New Comment' );

eocdOffset()

Returns the (unexpected) number of bytes between where the EOCD was found and where it expected to be πŸ‘€ Normally this is 0, but it'd be positive if something (a virus, perhaps πŸ’€) had added bytes somewhere before the EOCD. Not used for writing zips, but might be interesting if you read a zip in. Here's how you can diagnose it:

my $zip = Archive::Zip->new('somefile.zip');
if ($zip->eocdOffset())
{
  warn "A virus has added ", $zip->eocdOffset, " bytes of garbage\n";
}

The eocdOffset() is used to adjust the starting position of member headers, if necessary 🫢

fileName()

Returns the name of the file last read from. If nothing's been read yet, returns an empty string; if it was read from a file handle, returns the handle in string form 🌸


🧚 Zip Archive Member Operations 🧚

So like, various operations on a zip file modify members. When a member gets passed in as an argument, you can either use a reference to the member itself, or the name of a member. Obviously using the name requires that names be unique within a zip β€” and no, that is not enforced πŸ™ˆ

removeMember( $memberOrName )

removeMember( { memberOrZipName => $memberOrName } )

Removes and returns the given member, or matches its name and removes it. Returns undef if the member or name doesn't exist in this Zip. Total no-op if the member doesn't belong to this zip πŸ’…

replaceMember( $memberOrName, $newMember )

replaceMember( { memberOrZipName => $memberOrName, newMember => $newMember } )

Removes and returns the given member, or matches its name and removes it β€” then replaces it with the new member. Returns undef if the member or name doesn't exist in this Zip, or if $newMember is undefined.

⚠️ It's an (undiagnosed) error to hand it a $newMember that's a member of the zip you're modifying. Don't do that.
my $member1 = $zip->removeMember( 'xyz' );
my $member2 = $zip->replaceMember( 'abc', $member1 );
# now, $member2 (named 'abc') is not in $zip,
# and $member1 (named 'xyz') is, having taken $member2's place.

extractMember( $memberOrName [, $extractedName ] )

extractMember( { memberOrZipName => $memberOrName [, name => $extractedName ] } )

Extracts the given member, or matches its name and extracts it. Returns undef if the member doesn't exist in this Zip 🌸

If you pass the optional second arg, it's used as the name of the extracted member. Otherwise the internal filename of the member is used as the name of the extracted file or directory. If you do pass $extractedName, it should be in the local file system's format.

🚨 If you do not pass $extractedName and the internal filename traverses a parent directory or a symbolic link, the extraction gets aborted with "AC_ERROR" for security reasons. Not negotiable, bestie.

All necessary directories get created for you ✨ Returns "AZ_OK" on success.

extractMemberWithoutPaths( $memberOrName [, $extractedName ] )

extractMemberWithoutPaths( { memberOrZipName => $memberOrName [, name => $extractedName ] } )

Extracts the given member, or matches its name and extracts it β€” but does not use path information (so it extracts into the current directory) πŸŽ€

Returns undef if the member doesn't exist in this Zip. If you pass the optional second arg, it's used as the name of the extracted member (its paths get deleted too). Otherwise the internal filename of the member (minus paths) is used as the name of the extracted file or directory. Returns "AZ_OK" on success.

🚨 If you do not pass $extractedName and the internal filename is equalled to a local symbolic link, the extraction gets aborted with "AC_ERROR" for security reasons.

addMember( $member )

addMember( { member => $member } )

Appends a member (possibly one from another zip file) to the zip file. Returns the new member πŸ‘‘

Generally you'll use addFile(), addDirectory(), addFileOrDirectory(), addString(), or read() to add members.

# Move member named 'abc' to end of zip:
my $member = $zip->removeMember( 'abc' );
$zip->addMember( $member );

updateMember( $memberOrName, $fileName )

updateMember( { memberOrZipName => $memberOrName, name => $fileName } )

Updates a single member from the file or directory named $fileName. Returns the (possibly added or updated) member, if any; "undef" on errors πŸ’€

The comparison is based on lastModTime() and (in the case of a non-directory) the size of the file.

addFile( $fileName [, $newName, $compressionLevel ] )

addFile( { filename => $fileName [, zipName => $newName, compressionLevel => $compressionLevel } ] )

Appends a member whose data comes from an external file, returning the member β€” or undef 😭

The member will have its file name set to the name of the external file, and its desiredCompressionMethod set to COMPRESSION_DEFLATED. The file attributes and last modification time get set from the file ✨

If the name you give doesn't represent a readable plain file or symbolic link, undef gets returned. $fileName must be in the format required for the local file system.

The optional $newName argument sets the internal file name to something different than the given $fileName. $newName, if given, must be in Zip name format (i.e. Unix). The text mode bit gets set if the contents appear to be text (as returned by the "-T" perl operator) πŸŽ€

⚠️ NOTE that you should not (generally) use absolute path names in zip member names β€” it causes problems with some zip tools, introduces a security hole, and makes the zip harder to use. Just don't, bestie πŸ’…
  • addDirectory( $directoryName [, $fileName ] ) β€” the simple form, no cap
  • addDirectory( { directoryName => $directoryName [, zipName => $fileName ] } ) β€” the fancy hashref form, same energy

Both of these append a member made out of the directory name you hand them πŸ’– And here's the cute part: the directory name does not have to name an existing directory. Like, it can be purely aspirational. But if that directory does exist, the file modification time and permissions get set from the real directory; if it doesn't, they're set to now and permissive default permissions. $directoryName must be in local file system format. The optional second argument sets the name of the archive member (which defaults to $directoryName) β€” and if you pass it, it must be in Zip (Unix) format. Returns the new member. Slay ✨


  • addFileOrDirectory( $name [, $newName, $compressionLevel ] ) β€” append a member from a file or a directory
  • addFileOrDirectory( { name => $name [, zipName => $newName, compressionLevel => $compressionLevel ] } ) β€” same thing, hashref flavored

Appends a member from the file or directory named $name. If $newName is given, it's used as the name of the new member β€” and it will add or remove trailing slashes from $newName as needed (it's giving thoughtful). $name must be in local file system format. The optional second argument sets the name of the archive member, which defaults to $name; if given, it must be in Zip (Unix) format.


  • addString( $stringOrStringRef, $name, [$compressionLevel] ) β€” string goes in, member comes out
  • addString( { string => $stringOrStringRef [, zipName => $name, compressionLevel => $compressionLevel ] } ) β€” hashref version, iykyk

Appends a member created from the given string or string reference πŸŽ€ The name is given by the second argument. Returns the new member. The last modification time will be set to now, and the file attributes will be set to permissive defaults. Lowkey the easiest way to shove text in a zip:

my $member = $zip->addString( 'This is a test', 'test.txt' );

  • contents( $memberOrMemberName [, $newContents ] ) β€” get (or set!) the uncompressed data for a member
  • contents( { memberOrZipName => $memberOrMemberName [, contents => $newContents ] } ) β€” hashref flex

Returns the uncompressed data for a particular member, or undef (πŸ’€ when it's a miss).

print "xyz.txt contains " . $zip->contents( 'xyz.txt' );

It can also change the contents of a member, no cap:

$zip->contents( 'xyz.txt', 'This is the new contents' );

And if you call it expecting an array as the return value, it'll include the status as the second value in the array 🫢

($content, $status) = $zip->contents( 'xyz.txt');

πŸ’Ύ Zip Archive I/O operations πŸ’Ύ

A Zip archive can be written to a file or file handle, or read from one. That's the whole vibe of this section, bestie ⭐

writeToFileNamed( $fileName ) / writeToFileNamed( { fileName => $fileName } )

Write a zip archive to a named file. Returns "AZ_OK" on success πŸ‘‘

my $status = $zip->writeToFileNamed( 'xx.zip' );
die "error somewhere" if $status != AZ_OK;
Careful, bestie 🚨 Note that if you use the same name as an existing zip file that you read in, you will clobber ZipFileMembers. So instead, write to a different file name, then delete the original. If you use the overwrite() or overwriteAs() methods, you can re-write the original zip in this way. $fileName should be a valid file name on your system.

writeToFileHandle( $fileHandle [, $seekable ] )

Write a zip archive to a file handle. Returns AZ_OK on success. The optional second arg tells whether or not to try to seek backwards to re-write headers. If it's not provided, it's set if the Perl -f test returns true. That could fail on some operating systems, though πŸ™ˆ

my $fh = IO::File->new( 'someFile.zip', 'w' );
unless ( $zip->writeToFileHandle( $fh ) == AZ_OK ) {
    # error handling
}

If you pass a file handle that is not seekable β€” like if you're writing to a pipe or a socket β€” pass a false second argument:

my $fh = IO::File->new( '| cat > somefile.zip', 'w' );
$zip->writeToFileHandle( $fh, 0 );   # fh is not seekable

If this method fails during the write of a member, that member and all following it will return false from wasWritten(). See writeCentralDirectory() for a way to deal with this. And if you want, you can write data to the file handle before passing it to writeToFileHandle() β€” this could be used (for instance) for making self-extracting archives ✨ However, this only works reliably when writing to a real file (as opposed to STDOUT or some other possible non-file).

See examples/selfex.pl for how to write a self-extracting archive. Iconic.

writeCentralDirectory( $fileHandle [, $offset ] ) / writeCentralDirectory( { fileHandle => $fileHandle [, offset => $offset ] } )

Writes the central directory structure to the given file handle πŸ“

Returns AZ_OK on success. If given an $offset, it will seek to that point before writing. This can be used for recovery in cases where writeToFileHandle or writeToFileNamed returns an IO error because of running out of space on the destination file. Literally the rescue plan πŸ’…

You can truncate the zip by seeking backwards and then writing the directory:

my $fh = IO::File->new( 'someFile.zip', 'w' );
    my $retval = $zip->writeToFileHandle( $fh );
if ( $retval == AZ_IO_ERROR ) {
    my @unwritten = grep { not $_->wasWritten() } $zip->members();
    if (@unwritten) {
        $zip->removeMember( $member ) foreach my $member ( @unwritten );
        $zip->writeCentralDirectory( $fh,
        $unwritten[0]->writeLocalHeaderRelativeOffset());
    }
}

overwriteAs( $newName ) / overwriteAs( { filename => $newName } )

Write the zip to the specified file, as safely as possible πŸ›Ÿ This is done by first writing to a temp file, then renaming the original if it exists, then renaming the temp file, then deleting the renamed original if it exists. Returns AZ_OK if successful. Main character energy: it does the risky stuff off to the side first.

overwrite()

Write back to the original zip file. See overwriteAs() above. If the zip was not ever read from a file, this generates an error 🫠

read( $fileName ) / read( { filename => $fileName } )

Read zipfile headers from a zip file, appending new members. Returns "AZ_OK" or an error code.

my $zipFile = Archive::Zip->new();
my $status = $zipFile->read( '/some/FileName.zip' );

readFromFileHandle( $fileHandle, $filename ) / readFromFileHandle( { fileHandle => $fileHandle, filename => $filename } )

Read zipfile headers from an already-opened file handle, appending new members. Does not close the file handle. Returns "AZ_OK" or an error code.

Heads up πŸ“ Note that this requires a seekable file handle; reading from a stream is not yet supported, but using in-memory data is. Slay for in-memory data, honestly.
my $fh = IO::File->new( '/some/FileName.zip', 'r' );
my $zip1 = Archive::Zip->new();
my $status = $zip1->readFromFileHandle( $fh );
my $zip2 = Archive::Zip->new();
$status = $zip2->readFromFileHandle( $fh );

Read zip using in-memory data (recursable) 🧚:

open my $fh, "<", "archive.zip" or die $!;
my $zip_data = do { local $.; <$fh> };
my $zip = Archive::Zip->new;
open my $dh, "+<", \$zip_data;
$zip->readFromFileHandle ($dh);

🌳 Zip Archive Tree operations 🌳

These used to live in Archive::Zip::Tree but got moved into Archive::Zip. They enable operation on an entire tree of members or files β€” whole vibes, wholesale 🌈 A usage example:

use Archive::Zip;
my $zip = Archive::Zip->new();

# add all readable files and directories below . as xyz/*
$zip->addTree( '.', 'xyz' );

# add all readable plain files below /abc as def/*
$zip->addTree( '/abc', 'def', sub { -f && -r } );

# add all .c files below /tmp as stuff/*
$zip->addTreeMatching( '/tmp', 'stuff', '\.c$' );

# add all .o files below /tmp as stuff/* if they aren't writable
$zip->addTreeMatching( '/tmp', 'stuff', '\.o$', sub { ! -w } );

# add all .so files below /tmp that are smaller than 200 bytes as stuff/*
$zip->addTreeMatching( '/tmp', 'stuff', '\.o$', sub { -s < 200 } );

# and write them into a file
$zip->writeToFileNamed('xxx.zip');

# now extract the same files into /tmpx
$zip->extractTree( 'stuff', '/tmpx' );

$zip->addTree( $root, $dest [, $pred, $compressionLevel ] ) β€” add tree of files to a zip

$zip->addTree( { root => $root, zipName => $dest [, select => $pred, compressionLevel => $compressionLevel ] } )

$root is the root of the tree of files and directories to be added. It is a valid directory name on your system. $dest is the name for the root in the zip file (undef or blank means to use relative pathnames). It is a valid ZIP directory name β€” that is, it uses forward slashes (/) for separating directory components. $pred is an optional subroutine reference to select files: it's passed the name of the prospective file or directory using $_, and if it returns true, the file or directory will be included. The default is to add all readable files and directories πŸ’–

For instance, using

my $pred = sub { /\.txt/ };
$zip->addTree( '.', '', $pred );

will add all the .txt files in and below the current directory, using relative names, and making the names identical in the zipfile:

original name           zip member name
./xyz                   xyz
./a/                    a/
./a/b                   a/b

To translate absolute to relative pathnames, just pass them in: $zip->addTree( '/c/d', 'a' );

original name           zip member name
/c/d/xyz                a/xyz
/c/d/a/                 a/a/
/c/d/a/b                a/a/b

Returns AZ_OK on success. Note that this will not follow symbolic links to directories. Note also that this does not check for the validity of filenames ⚠️

Real talk πŸ¦‹ Note that you generally don't want to make zip archive member names absolute.

$zip->addTreeMatching( $root, $dest, $pattern [, $pred, $compressionLevel ] )

$zip->addTreeMatching( { root => $root, zipName => $dest, pattern => $pattern [, select => $pred, compressionLevel => $compressionLevel ] } )

$root is the root of the tree of files and directories to be added. $dest is the name for the root in the zip file (undef means to use relative pathnames). $pattern is a (non-anchored) regular expression for filenames to match. $pred is an optional subroutine reference to select files: it's passed the name of the prospective file or directory in $_, and if it returns true, the file or directory will be included. The default is to add all readable files and directories πŸ’œ

To add all files in and below the current directory whose names end in .pl, and make them extract into a subdirectory named xyz, do this:

$zip->addTreeMatching( '.', 'xyz', '\.pl$' )

So say you wanna add every writable file in and below the directory named /abc whose names end in .pl, and have them all extract into a subdirectory named xyz β€” bestie, you'd do this:

$zip->addTreeMatching( '/abc', 'xyz', '\.pl$', sub { -w } )

Returns AZ_OK on success. Small heads-up: this will not follow symbolic links to directories. It's giving "boundaries", honestly. πŸ’…


πŸŒ€ $zip->updateTree(...)

Both flavors, coming right up:

$zip->updateTree( $root [, $dest , $pred , $mirror, $compressionLevel ] );
$zip->updateTree( { root => $root [, zipName => $dest, select => $pred, mirror => $mirror, compressionLevel => $compressionLevel ] } );

This one updates a zip file from a directory tree. ✨

updateTree() takes the same arguments as addTree(), but first it checks whether the file or directory already exists in the zip file, and whether it's been changed. Like, it does a vibe check before committing. 🫢

If the fourth argument $mirror is true, then delete all my members if corresponding files were not found.

Returns an error code or AZ_OK if all is well.


🌳 $zip->extractTree(...)

$zip->extractTree( [ $root, $dest, $volume } ] )
$zip->extractTree( [ { root => $root, zipName => $dest, volume => $volume } ] )

(Don't look at me about that stray } in the first signature β€” it's staying exactly as it is. πŸ’€)

If you don't give any arguments at all, it will extract all the files in the zip with their original names. Easy mode, no cap. ✨

If you supply one argument for $root, extractTree will extract all the members whose names start with $root into the current directory, stripping off $root first. $root is in Zip (Unix) format. For instance:

$zip->extractTree( 'a' );

when applied to a zip containing the files a/x a/b/c ax/d/e d/e will extract:

a/x as ./x

a/b/c as ./b/c

If you give two arguments, extractTree extracts all the members whose names start with $root. It will translate $root into $dest to construct the destination file name. $root and $dest are in Zip (Unix) format. For instance:

$zip->extractTree( 'a', 'd/e' );

when applied to a zip containing the files a/x a/b/c ax/d/e d/e will extract:

a/x to d/e/x

a/b/c to d/e/b/c and ignore ax/d/e and d/e

If you give three arguments, extractTree extracts all the members whose names start with $root. It will translate $root into $dest to construct the destination file name, and then it will convert to local file system format, using $volume as the name of the destination volume.

$root and $dest are in Zip (Unix) format.

$volume is in local file system format.

For instance, under Windows:

$zip->extractTree( 'a', 'd/e', 'f:' );

when applied to a zip containing the files a/x a/b/c ax/d/e d/e will extract:

a/x to f:d/e/x

a/b/c to f:d/e/b/c and ignore ax/d/e and d/e

If you want absolute paths (the prior example used paths relative to the current directory on the destination volume), you can specify these in $dest:

$zip->extractTree( 'a', '/d/e', 'f:' );

when applied to a zip containing the files a/x a/b/c ax/d/e d/e will extract:

a/x to f:\d\e\x

a/b/c to f:\d\e\b\c and ignore ax/d/e and d/e

🚨 If the path to the extracted file traverses a parent directory or a symbolic link, the extraction will be aborted with AC_ERROR for security reason. Not messing around with that one, periodt. Returns an error code or AZ_OK if everything worked OK.

🌍 Archive::Zip Global Variables

πŸ’œ $Archive::Zip::UNICODE

This variable governs how Unicode file and directory names are added to or extracted from an archive. If set, file and directory names are considered to be UTF-8 encoded. This is EXPERIMENTAL AND BUGGY (there are some edge cases on Win32). Please report problems. πŸ™

{
    local $Archive::Zip::UNICODE = 1;
    $zip->addFile('DΓ©jΓ  vu.txt');
}

πŸŽ€ MEMBER OPERATIONS

πŸ’… Member Class Methods

Several constructors let you construct members without adding them to a zip archive. These work the same as the addFile(), addDirectory(), and addString() zip instance methods described above, but they don't add the new members to a zip. Iconic, low-commitment behavior. πŸ¦‹

  • Archive::Zip::Member->newFromString( $stringOrStringRef [, $fileName ] ) β€” and also Archive::Zip::Member->newFromString( { string => $stringOrStringRef [, zipName => $fileName ] } ). Constructs a new member from the given string. Returns undef on error.
my $member = Archive::Zip::Member->newFromString( 'This is a test' );
my $member = Archive::Zip::Member->newFromString( 'This is a test', 'test.txt' );
my $member = Archive::Zip::Member->newFromString( { string => 'This is a test', zipName => 'test.txt' } );
  • newFromFile( $fileName [, $zipName ] ) β€” and also newFromFile( { filename => $fileName [, zipName => $zipName ] } ). Constructs a new member from the given file. Returns undef on error.
my $member = Archive::Zip::Member->newFromFile( 'xyz.txt' );
  • newDirectoryNamed( $directoryName [, $zipname ] ) β€” and also newDirectoryNamed( { directoryName => $directoryName [, zipName => $zipname ] } ). Constructs a new member from the given directory. $directoryName must be a valid name on your file system; it does not have to exist. If given, $zipname will be the name of the zip member; it must be a valid Zip (Unix) name. If not given, it will be converted from $directoryName. Returns undef on error.
my $member = Archive::Zip::Member->newDirectoryNamed( 'CVS/' );

πŸ” Member Simple Accessors

These methods get (and/or set) member attribute values. Glow-up for your metadata. ✨

The zip64 format requires parts of the member data to be stored in the so-called extra fields. You cannot get nor set this zip64 data through the extra field accessors described in this section. In fact, the low-level member methods ensure that the zip64 data in the extra fields is handled completely transparently and invisibly to the user when members are read or written. It's giving main character who does their own stunts off-screen. 🎭

  • zip64() β€” Returns whether the previous read or write of the member has been done in zip64 format.
  • desiredZip64Mode() β€” Gets or sets whether the member's headers should be written in zip64 format: As needed (ZIP64_AS_NEEDED), the default, or always (ZIP64_HEADERS).
  • versionMadeBy() β€” Gets the field from the member header.
  • fileAttributeFormat( [ $format ] ) β€” or fileAttributeFormat( [ { format => $format ] } ). Gets or sets the field from the member header. These are FA_* values.
  • versionNeededToExtract() β€” Gets the field from the member header.
  • bitFlag() β€” Gets the general purpose bit field from the member header. This is where the GPBF_* bits live. 🏠
  • compressionMethod() β€” Returns the member compression method. This is the method that is currently being used to compress the member data. This will be COMPRESSION_STORED for added string or file members, or any of the COMPRESSION_* values for members from a zip file. However, this module can only handle members whose data is in COMPRESSION_STORED or COMPRESSION_DEFLATED format.
  • desiredCompressionMethod( [ $method ] ) β€” or desiredCompressionMethod( [ { compressionMethod => $method } ] ). Get or set the member's "desiredCompressionMethod". This is the compression method that will be used when the member is written. Returns prior desiredCompressionMethod. Only COMPRESSION_DEFLATED or COMPRESSION_STORED are valid arguments. Changing to COMPRESSION_STORED will change the member desiredCompressionLevel to 0; changing to COMPRESSION_DEFLATED will change the member desiredCompressionLevel to COMPRESSION_LEVEL_DEFAULT.
  • desiredCompressionLevel( [ $level ] ) β€” or desiredCompressionLevel( [ { compressionLevel => $level } ] ). Get or set the member's desiredCompressionLevel. This is the method that will be used to write. Returns prior desiredCompressionLevel. Valid arguments are 0 through 9, COMPRESSION_LEVEL_NONE, COMPRESSION_LEVEL_DEFAULT, COMPRESSION_LEVEL_BEST_COMPRESSION, and COMPRESSION_LEVEL_FASTEST. 0 or COMPRESSION_LEVEL_NONE will change the desiredCompressionMethod to COMPRESSION_STORED. All other arguments will change the desiredCompressionMethod to COMPRESSION_DEFLATED.
  • externalFileName() β€” Return the member's external file name, if any, or undef.
  • fileName() β€” Get or set the member's internal filename. Returns the (possibly new) filename. Names will have backslashes converted to forward slashes, and will have multiple consecutive slashes converted to single ones.
  • lastModFileDateTime() β€” Return the member's last modification date/time stamp in MS-DOS format.
  • lastModTime() β€” Return the member's last modification date/time stamp, converted to unix localtime format.
print "Mod Time: " . scalar( localtime( $member->lastModTime() ) );
  • setLastModFileDateTimeFromUnix() β€” Set the member's lastModFileDateTime from the given unix time.
$member->setLastModFileDateTimeFromUnix( time() );
  • internalFileAttributes() β€” Return the internal file attributes field from the zip header. This is only set for members read from a zip file.
  • externalFileAttributes() β€” Return member attributes as read from the ZIP file. Note that these are NOT UNIX! πŸ™ˆ
  • unixFileAttributes( [ $newAttributes ] ) β€” or unixFileAttributes( [ { attributes => $newAttributes } ] ). Get or set the member's file attributes using UNIX file attributes. Returns old attributes.
my $oldAttribs = $member->unixFileAttributes( 0666 );

Note that the return value has more than just the file permissions, so you will have to mask off the lowest bits for comparisons. Masking is self-care, bestie. πŸ’…

  • localExtraField( [ $newField ] ) β€” or localExtraField( [ { field => $newField } ] ). Gets or sets the extra field that was read from the local header. The extra field must be in the proper format. If it is not or if the new field contains data related to the zip64 format, this method does not modify the extra field and returns AZ_FORMAT_ERROR, otherwise it returns AZ_OK.
  • cdExtraField( [ $newField ] ) β€” or cdExtraField( [ { field => $newField } ] ). Gets or sets the extra field that was read from the central directory header. The extra field must be in the proper format. If it is not or if the new field contains data related to the zip64 format, this method does not modify the extra field and returns AZ_FORMAT_ERROR, otherwise it returns AZ_OK.
  • extraFields() β€” Return both local and CD extra fields, concatenated.
  • fileComment( [ $newComment ] ) β€” or fileComment( [ { comment => $newComment } ] ). Get or set the member's file comment. πŸŽ€
  • hasDataDescriptor() β€” get or set the data descriptor flag. When it's on, your local header won't necessarily have the correct data sizes β€” instead, a little structure gets stashed at the end of the member data with those values. This should be totally transparent in normal operation, no cap ✨
  • crc32() β€” returns the CRC-32 value for this member. Heads up bestie: it won't be set for members that were constructed from strings or external files until after the member has been written.
  • crc32String() β€” same CRC-32 value, but as an 8 character printable hex string. Also not set for string-built or external-file members until after writing πŸ’…
  • compressedSize() β€” returns the compressed size for this member. Again, not set for members constructed from strings or external files until after the member has been written.
  • uncompressedSize() β€” returns the uncompressed size for this member.
  • password( [ $password ] ) β€” returns the password for this member to be used on decryption. If you pass $password, it sets the password for the decryption πŸ”
  • isEncrypted() β€” returns true if this member is encrypted. The Archive::Zip module does not currently support creation of encrypted members (periodt). Decryption works more or less like this:
my $zip = Archive::Zip->new;
$zip->read ("encrypted.zip");
for my $m (map { $zip->memberNamed ($_) } $zip->memberNames) {
    $m->password ("secret");
    $m->contents;  # is "" when password was wrong
}

That shows the password has to be set per member, not per archive. This might change in the future πŸ‘€

  • isTextFile( [ $flag ] ) / isTextFile( [ { flag => $flag } ] ) β€” returns true if I am a text file. Also can set the status if given an argument (then returns old state). Note that this module does not currently do anything with this flag upon extraction or storage. That is, bytes are stored in native format whether or not they came from a text file πŸ’€
  • isBinaryFile() β€” returns true if I am a binary file. Also can set the status if given an argument (then returns old state). Note that this module does not currently do anything with this flag upon extraction or storage. That is, bytes are stored in native format whether or not they came from a text file. Same vibe, different flag 🫢
  • extractToFileNamed( $fileName ) / extractToFileNamed( { name => $fileName } ) β€” extract me to a file with the given name. The file will be created with default modes. Directories will be created as needed. The $fileName argument should be a valid file name on your file system. Returns AZ_OK on success 🌸
  • isDirectory() β€” returns true if I am a directory πŸ“
  • isSymbolicLink() β€” returns true if I am a symbolic link πŸ”—
  • writeLocalHeaderRelativeOffset() β€” returns the file offset in bytes the last time I was written.
  • wasWritten() β€” returns true if I was successfully written. Reset at the beginning of a write attempt.

🫢 Low-level member data reading 🫢

It is possible to use lower-level routines to access member data streams, rather than the extract* methods and contents(). For instance, here is how to print the uncompressed contents of a member in chunks using these methods:

my ( $member, $status, $bufferRef );
$member = $zip->memberNamed( 'xyz.txt' );
$member->desiredCompressionMethod( COMPRESSION_STORED );
$status = $member->rewindData();
die "error $status" unless $status == AZ_OK;
while ( ! $member->readIsDone() )
{
( $bufferRef, $status ) = $member->readChunk();
die "error $status"
            if $status != AZ_OK && $status != AZ_STREAM_END;
# do something with $bufferRef:
print $$bufferRef;
}
$member->endRead();
  • readChunk( [ $chunkSize ] ) / readChunk( [ { chunkSize => $chunkSize } ] ) β€” this reads the next chunk of given size from the member's data stream and compresses or uncompresses it as necessary, returning a reference to the bytes read and a status. If the size argument is not given, it defaults to the global set by Archive::Zip::setChunkSize. Status is AZ_OK on success until the last chunk, where it returns AZ_STREAM_END. Returns ( \$bytes, $status).
my ( $outRef, $status ) = $self->readChunk();
print $$outRef if $status != AZ_OK && $status != AZ_STREAM_END;
  • rewindData() β€” rewind data and set up for reading data streams or writing zip files. Can take options for inflateInit() or deflateInit(), but this is not likely to be necessary. Subclass overrides should call this method. Returns AZ_OK on success.
  • endRead() β€” reset the read variables and free the inflater or deflater. Must be called to close files, etc. Returns AZ_OK on success.
  • readIsDone() β€” return true if the read has run out of data or encountered an error.
  • contents() β€” return the entire uncompressed member data, or undef in scalar context. When called in array context, returns ( $string, $status ); status will be AZ_OK on success:
my $string = $member->contents();
# or
my ( $string, $status ) = $member->contents();
die "error $status" unless $status == AZ_OK;

Can also be used to set the contents of a member (this may change the class of the member):

$member->contents( "this is my new contents" );
  • extractToFileHandle( $fh ) / extractToFileHandle( { fileHandle => $fh } ) β€” extract (and uncompress, if necessary) the member's contents to the given file handle. Return AZ_OK on success.

For members representing symbolic links, pass the name of the symbolic link as file handle. Ensure that all directories in the path to the symbolic link already exist. No skipping that step, bestie πŸ’…

πŸ¦‹ Archive::Zip::FileMember methods πŸ¦‹

The Archive::Zip::FileMember class extends Archive::Zip::Member. It is the base class for both ZipFileMember and NewFileMember classes. This class adds an "externalFileName" and an "fh" member to keep track of the external file.

  • externalFileName() β€” return the member's external filename.
  • fh() β€” return the member's read file handle. Automatically opens the file if necessary ✨

πŸ‘‘ Archive::Zip::ZipFileMember methods πŸ‘‘

The Archive::Zip::ZipFileMember class represents members that have been read from external zip files.

  • diskNumberStart() β€” returns the disk number that the member's local header resides in. Should be 0.
  • localHeaderRelativeOffset() β€” returns the offset into the zip file where the member's local header is.
  • dataOffset() β€” returns the offset from the beginning of the zip file to the member's data.

⭐ REQUIRED MODULES ⭐

Archive::Zip requires several other modules:

  • Carp
  • Compress::Raw::Zlib
  • Cwd
  • File::Basename
  • File::Copy
  • File::Find
  • File::Path
  • File::Spec
  • IO::File
  • IO::Seekable
  • Time::Local

πŸ’€ BUGS AND CAVEATS πŸ’€

When not to use Archive::Zip

If you are just going to be extracting zips (and/or other archives), you are recommended to look at using Archive::Extract instead, as it is much easier to use and factors out archive-specific functionality. Lowkey a better fit for that job 🫢

Zip64 Format Support

Since version 1.66, Archive::Zip supports the so-called zip64 format, which overcomes various limitations in the original zip file format. On some Perl interpreters, however, even version 1.66 and newer of Archive::Zip cannot support the zip64 format. Among these are all Perl interpreters that lack 64-bit support and those older than version 5.10.0.

Constant ZIP64_SUPPORTED, exported with tag :CONSTANTS, equals true if Archive::Zip on the current Perl interpreter supports the zip64 format. If it does not and you try to read or write an archive in zip64 format anyway, Archive::Zip returns an error AZ_ERROR and reports an error message along the lines of "zip64 format not supported on this Perl interpreter".

πŸ’… "versionMadeBy" and "versionNeededToExtract" πŸ’…

The zip64 format and the zip file format in general specify what values to use for the "versionMadeBy" and "versionNeededToExtract" fields in the local file header, central directory file header, and zip64 EOCD record. In practice however, these fields seem to be more or less randomly used by various archiver implementations. Chaos, honestly 😭

To achieve a compromise between backward compatibility and (whatever) standard compliance, Archive::Zip handles them as follows:

  • For field "versionMadeBy", Archive::Zip uses default value 20 (45 for the zip64 EOCD record) or any previously read value. It never changes that value when writing a header, even if it is written in zip64 format, or when writing the zip64 EOCD record.
  • Likewise for field "versionNeededToExtract", but here Archive::Zip forces a minimum value of 45 when writing a header in zip64 format or the zip64 EOCD record.
  • Finally, Archive::Zip never depends on the values of these fields in any way when reading an archive from a file or file handle.

Try to avoid IO::Scalar

One of the most common ways to use Archive::Zip is to generate Zip files in-memory. Most people use IO::Scalar for this purpose.

Unfortunately, as of 1.11 this module no longer works with IO::Scalar as it incorrectly implements seeking. Big yikes πŸ’€

Anybody using IO::Scalar should consider porting to IO::String, which is smaller, lighter, and is implemented to be perfectly compatible with regular seekable filehandles.

Support for IO::Scalar most likely will not be restored in the future, as IO::Scalar itself cannot change the way it is implemented due to back-compatibility issues.

Wrong password for encrypted members

When an encrypted member is read using the wrong password, you currently have to re-read the entire archive to try again with the correct password. Annoying? Yes. Changing soon? Maybe. πŸ™ˆ

🌈 TO DO 🌈

  • auto-choosing storing vs compression
  • extra field hooks (see notes.txt)
  • check for duplicates on addition/renaming?
  • Text file extraction (line end translation)
  • Reading zip files from non-seekable inputs (Perhaps by proxying through IO::String?)
  • separate unused constants into separate module
  • cookbook style docs
  • Handle tainted paths correctly
  • Work on better compatibility with other IO:: modules
  • Support encryption
  • More user-friendly decryption

🫢 SUPPORT 🫢

Bugs should be reported on GitHub:

<https://github.com/redhotpenguin/perl-Archive-Zip/issues>

For other issues contact the maintainer.

πŸ’– AUTHOR πŸ’–

okay so who even made this thing, right? bestie, it's a whole relay race of iconic maintainers and we're gonna give everyone their flowers 🌸

  • Right now, today, currently it's maintained by Fred Moyer <fred@redhotpenguin.com> β€” say thank you to Fred fr fr 🫢
  • Before that it was maintained by Adam Kennedy <adamk@cpan.org> β€” lowkey a legend
  • And before that it was maintained by Steve Peters <steve@fisharerojo.org> β€” the way this page has lore 😭
  • The file attributes code is by Maurice Aubrey <maurice@lovelyfilth.com> β€” we love a specialist πŸ’…
  • And originally it was by Ned Konz <nedkonz@cpan.org> β€” the founding mother, if you will πŸ‘‘

the legal bit, but make it cute. no cap, you still gotta read it:

  • Some parts copyright 2006 - 2012 Adam Kennedy ✨
  • Some parts copyright 2005 Steve Peters ✨
  • Original work copyright 2000 - 2004 Ned Konz ✨

and now the part that actually matters to you, bestie, listen up:

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

that's it, that's the vibe. free as in go off, queen πŸ¦‹


✨ SEE ALSO ✨

more reading, because you're a curious little main character and I respect that πŸ’œ

  • Go look at Archive::Zip::MemberRead β€” it's a wrapper that lets you read Zip archive members as if they were files. it's giving "files but secret" πŸ‘€
  • Compress::Raw::Zlib β€” the zlib guts, lowkey essential
  • Archive::Tar β€” same energy, different archive format πŸ“
  • Archive::Extract β€” the "just handle it for me" option, we stan a convenient icon 🌈

that's the whole page, bestie!! you made it to the end, I'm so proud, genuinely πŸ˜­πŸ’– go zip something iconic. mwah πŸ’‹

this little beauty comes from perl v5.42.0, dated 2020-03-13, and yes, it's Archive::Zip(3) β€” icon behavior only πŸ‘‘

πŸ“¦ where this page comes from