简体   繁体   English

如何使用Perl的Archive :: Zip从ZIP存档中提取单个文件?

[英]How can I extract a single file from a ZIP archive using Perl's Archive::Zip?

I have a zip file X and I'd like do extract a single file, located in x/x/x/file.txt . 我有一个zip文件X,我想提取一个文件,位于x / x / x / file.txt How do I do this using Archive::Zip and Perl? 我如何使用Archive::Zip和Perl执行此操作?

You can use the extractMember method: 您可以使用extractMember方法:

extractMember( $memberOrName [, $extractedName ] ) extractMember($ memberOrName [,$ extractedName])

Extract the given member, or match its name and extract it. 提取给定成员,或匹配其名称并将其解压缩。 Returns undef if member doesn't exist in this Zip. 如果此Zip中不存在成员,则返回undef。 If optional second arg is given, use it as the name of the extracted member. 如果给出了可选的第二个arg,则使用它作为提取的成员的名称。 Otherwise, the internal filename of the member is used as the name of the extracted file or directory. 否则,该成员的内部文件名将用作提取的文件或目录的名称。 If you pass $extractedName, it should be in the local file system's format. 如果传递$ extractedName,它应该是本地文件系统的格式。 All necessary directories will be created. 将创建所有必需的目录。 Returns AZ_OK on success. 成功时返回AZ_OK。

See Archive::Zip::FAQ , "extract file(s) from a Zip". 请参阅Archive :: Zip :: FAQ ,“从Zip中提取文件”。 The current version of the example file is online at http://cpansearch.perl.org/src/ADAMK/Archive-Zip-1.30/examples/extract.pl . 当前版本的示例文件位于http://cpansearch.perl.org/src/ADAMK/Archive-Zip-1.30/examples/extract.pl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM