in reply to Re^2: check *.tmp wether it's a zip or not
in thread check *.tmp wether it's a zip or not

In which case, one might consider a local $SIG{__WARN__} handler:

sub is_zip { #Load the file local $SIG{__WARN__} = sub { goto CONTINUE }; $status = $zip->read($file); CONTINUE: #Check $status }

The code above is bad (it's an idea only), but the basic idea is to have a __WARN__ handler that supresses printing of the error and then branches to a goto tag outside itself, which keeps the default handler from being called.

However, using mime-magic to determine the file type is probably better.

#Read data into $file if ($file =~ m/^\x50\x4B\x03\x04/) { #Parse as ZIP file } else { #Parse as something else }

Or automate that type of task with the previously-mentioned File::Type module.


radiantmatrix
require General::Disclaimer;
Perl is