use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); use File::Spec; use strict; use warnings; my $zipfile = shift or die "What's the zipfile?"; my $dir = shift or die "Where's the dir?"; my $zip = Archive::Zip->new(); opendir my $dh, $dir or die $!; while (readdir $dh) { next if !/\.lib$/; $zip->addFile(File::Spec->catfile($dir, $_), $_); } closedir $dh; # Save the Zip file unless ( $zip->writeToFileNamed($zipfile) == AZ_OK ) { die 'write error'; }