0





143

Advertisement

I am using Archive::Zip to create archive files, I'd like to know if I can add a file to an already existing archive? looks like every time I call ->writeToFileNamed the file is truncated...

Question author User3174311 | Source

Advertisement


0


use strict;
use warnings;
use Archive::Zip;

my $zip = Archive::Zip->new();
#create your archive
my $member = #"file you want to add to archive";
$zip->addMember( $member );

If you don't create your zip inside your script, then just "read" it and add your file...

use warnings;

use strict;

use Archive::Zip qw( :ERROR_CODES );

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

$zip->read('c:\users\user\desktop\test.zip') == AZ_OK or die "read error\n";

$zip->addFile('test.pl');

$zip->overwrite()     == AZ_OK or die "write error\n";
Answer author John-doe