开发者

Append a text File inside a Zip

开发者 https://www.devze.com 2023-01-01 15:40 出处:网络
I have zip file inside a Text file (file.txt inside a file.zip) and I would like to append to this file another text file file.txt outside the zip file.

I have zip file inside a Text file (file.txt inside a file.zip) and I would like to append to this file another text file file.txt outside the zip file. How can I do this? Is there a solution?

I've tried to add Append =>1 parameters 开发者_如何学Cto IO::Compress::Zip but the file inside the zip been overwritten ..

use IO::Compress::Zip qw(zip $ZipError) ;

$filenameToZip = 'file.txt';
zip $filenameToZip => "file.zip",Append => 1
    or die "zip failed: $ZipError\n";

Do I need to decompress the zip file, append/merge the two TXT file's and compress the file again? Or is there a better solution?


I would recommend using the Archive::Zip module rather than the lower-level module. Unless you know otherwise, I would expect IO::Compress::Zip to know how to do Zip-style compression, but not how to manipulate a Zip archive file.

The documentation for IO::Compress::Zip says:

This module provides a Perl interface that allows writing zip compressed data to files or buffer.

The primary purpose of this module is to provide streaming write access to zip files and buffers. It is not a general-purpose file archiver. If that is what you want, check out Archive::Zip.

0

精彩评论

暂无评论...
验证码 换一张
取 消