1
# Shows how to update a Zip in place using a temp file.
4
use Archive::Zip qw(:ERROR_CODES);
7
my $zipName = shift || die 'must provide a zip name';
9
die 'must provide file names' unless scalar(@fileNames);
12
my $zip = Archive::Zip->new();
13
die "can't read $zipName\n" unless $zip->read($zipName) == AZ_OK;
16
foreach my $file (@fileNames)
18
$zip->removeMember($file);
23
$zip->addFile($file) or die "Can't add $file to zip!\n";
27
$zip->addDirectory($file) or die "Can't add $file to zip!\n";
31
warn "Don't know how to add $file\n";
36
warn "Can't read $file\n";
40
# Now the zip is updated. Write it back via a temp file.
42
exit( $zip->overwrite() );