如何使用 Perl 列出 ZIP 文件的内容?
我的目标就是标题中所说的。
我有以下代码行,它只是打印出 [view archive]
,当我单击它时,浏览器只会下载 zip 文件。
print "\<a href=\"http:\/\/intranet.domain.com\/~devcvs\/view-file.cgi?file=$reviewdata{'document'}&review_id=$reviewdata{'id'}\"\>[view archive]\<\/a\>\n";
我想做的是在页面上的任何位置列出此 zip 文件中包含的文件,例如在该链接链接到的下面甚至新页面上,并将文件名作为参数。
我相信一旦完成此操作,浏览器就应该处理剩下的事情,只需单击这些文件并在浏览器中查看它们,因为它们将是 pdf 和 html 文件,我预计不会有任何问题。
我确信有一个模块可以做到这一点,但我不确定如何使用它来实现我的目标。
非常感谢任何帮助。
What I am aiming to do is pretty much what it says in the title.
I have the following line of code which simply prints out [view archive]
and when I click it the browser just downloads the zip file.
print "\<a href=\"http:\/\/intranet.domain.com\/~devcvs\/view-file.cgi?file=$reviewdata{'document'}&review_id=$reviewdata{'id'}\"\>[view archive]\<\/a\>\n";
What I would love to do is to list the files contained within this zip file anywhere on the page, e.g. just underneath or even a new page which this link links to and takes the filename as a parameter.
I believe once this is done the browser should take care of the rest in terms of just clicking these files and viewing them in the browser as they will be pdfs and html files which I don't foresee any problems with.
I am sure there is a module that does this but I am unsure of how to accomplish my goal using it.
Any help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下
Archive::Zip
:Have a look at
Archive::Zip
:使用
Archive::Zip
肯定会让代码变得更简单,如果您要广泛处理 zip 文件,您可能应该安装该模块。然而,对于那些不想安装任何东西的人来说,有一种方法可以仅使用核心模块 IO::Uncompress::Unzip 来列出 zip 文件的内容(已经是任何标准 Perl 发行版的一部分) )。
Using
Archive::Zip
certainly makes the code easier, and you should probably install that module if you are going to work extensively on zip files.However, for those who prefer not to install anything, there is a way to list the content of a zip file just using the core module
IO::Uncompress::Unzip
(already part of any standard Perl distribution).