我正在使用Archive :: Zip创建存档文件,我想知道是否可以将文件添加到现有存档中?看起来每次我调用 - > writeToFileNamed该文件被截断...
答案 0 :(得分:2)
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 );
如果你没有在你的脚本中创建你的zip,那么只需“阅读”它并添加你的文件......
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";