I need to write a script that does the following:
1) Examines a bunch of files (specified on the command line or whatever).
2) If some of them are ZIP archives, check if they contain a file with a particular name.
3) If they do, print the name of the ZIP archive.
I have written the script and it works, but I have a couple of questions:
1) I use the Archive::ZIP package. Problem is, if I try to use it on a file that isn't a ZIP archive, it barfs a bunch of errors. I would have expected it to fail gracefully and return some kind of error code, if the file isn't a properly formatted ZIP archive - but I was unable to make it behave like this. I have circumvented the issue by checking if the file begins with the ZIP archive signature ("PK\003\004") before opening it with Archive::ZIP->new() but I was wondering if there was a more elegant way.
2) Given that I don't need to extract anything from the archive (only check if a file exists inside), perhaps using the whole Archive::ZIP package is an overkill? Is there a more efficient way?
In reply to Checking if a file is present in a ZIP archive by bontchev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |