Skip to content

Instantly share code, notes, and snippets.

Created Nov 27, 2012
What would you like to do?
Perl zip utility
#! perl -w
package ZipUtil;
use strict;
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
use Exporter 'import';
our @EXPORT = qw(unzip);
# for CLI
my ($zip_file, $out_file, $filter) = @ARGV;
unzip($zip_file, $out_file, $filter) if scalar @ARGV;
# for importers
sub unzip {
my ($zip_file, $out_file, $filter) = @_;
my $zip = Archive::Zip->new($zip_file);
unless ($zip->extractTree($filter || '', $out_file) == AZ_OK) {
warn "unzip not successful: $!\n";

This comment has been minimized.

Copy link

@volomike volomike commented Dec 3, 2015

Awesome. Waisted 2 hours trying different methods that work on older OSX (Snow Leopard) and it's default Perl for an installer I'm working on, and your code here was just the ticket to show me the fix. Why this isn't so well advertised and known for unzipping on Perl -- I'll never know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment