in reply to Re: Checking if a file is present in a ZIP archive
in thread Checking if a file is present in a ZIP archive

Yes, I did try trapping the error with eval but it didn't work - it still spews a bunch of errors. I haven't used eval before, so maybe I've messed something up; I'll try again.

But if the designers have decided that the archive-processing functions should be passed only valid ZIP files, then they should have also provided a function that lets the user test if a file is a valid ZIP file. For instance, the Archive::Extract package does have such a function, but I can't use that package for various reasons (it doesn't have a function for testing the presence of a file with a specified name in the archive and it requires the presence of an unarchiving program).

  • Comment on Re^2: Checking if a file is present in a ZIP archive

Replies are listed 'Best First'.
Re^3: Checking if a file is present in a ZIP archive
by Gulliver (Monk) on Mar 25, 2011 at 21:38 UTC

    I just tried eval also (you need a semicolon after the block following eval I found out) and it was the same.

    I also tried 'no warnings;' for the block containing the read($file) and that didn't help. I have always checked the file extensions before opening something but someone could clobber my file.

    I'm curious now to look under the hood of Archive::Zip even though I probably won't understand it.

      It is probably a wrapper for a library (ZLib?) that might be spewing to STDERR. I hate it when libraries do that.
Re^3: Checking if a file is present in a ZIP archive
by toolic (Bishop) on Mar 26, 2011 at 00:41 UTC
      Hi, I am using Archive::Zip for compressing files. I am struggling to zip a file with the name contain "ÅÄÖ" characters. Actually these characters are converted as some different symbol. Can anyone give any suggestion to zip a file with the name contain the characters "ÅÄÖ"? Thanks in advance.
        Even if you succeessfully zip those files, you can cause a headache to the person who will try to unzip them (e.g. if that person works on a different OS or under different locale). Been there, seen that.