in reply to Checking if a file is present in a ZIP archive
Your decision to check for a signature is a reasonable one.
It is fairly common to take the approach of doing something in an eval block, so that, if it fails for any reason, you will be able to detect that it has done so. (The built-in variable “$@” will have a value...)
This is actually a very good way to deal with these kinds of errors:
eval { ... something that might fail ... ... (if we made it this far, we didn't fail, so) check return-code } if ($@) { ... guess what, it failed ... } else { ... it didn't ... }
A lot of code these days is intentionally designed in such a way that, if it encounters an exceptional condition that is “plausible and reasonable,” it returns an error-code, but if it encounters a “this can’t possibly ever ever ever happen, but it just did” condition, it throws an exception via die or Carp. Maybe the designers decided that, if they are supposed to be getting a valid ZIP-file but instead they have a corrupted one (or a flat file containing the text of the Gettysburg Address...), it would be best to commit suicide. And I would not say that they were wrong.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Checking if a file is present in a ZIP archive
by bontchev (Sexton) on Mar 25, 2011 at 20:47 UTC | |
by Gulliver (Monk) on Mar 25, 2011 at 21:38 UTC | |
by Anonymous Monk on Mar 25, 2011 at 23:46 UTC | |
by toolic (Bishop) on Mar 26, 2011 at 00:41 UTC | |
by AATG_PERL_1010 (Initiate) on Oct 25, 2011 at 09:42 UTC | |
by choroba (Cardinal) on Oct 25, 2011 at 10:05 UTC |