I have a case where some files being added to the zip are in use by another application.
I saw the proposed fix to bug 43359, and I ported that into my 1.26 local copy.
but.. this code never gets to execute, as there is a stack dump traceback application fatal error.
So, I decided to use the setErrorHandler() routine to trap out and stop the fatal error..
BUT when the error handler would be called in _printerror() in Zip.pm
I get another fatal error 'not a CODE reference in Zip.pm line 329, which is the line that invokes the error handler routine..
my code
sub ZipErrors()
{
print @_;
}
$zip = Archive::Zip->new();
$zip->setErrorHandler( \<ZipErrors );
# repeat as required (some 100 files)
$zip->addFile( $file, $zfn ) unless $zip->memberNamed($zfn);
$zip->writeToFileNamed($fn);
crash...
not a CODE reference in Zip.pm line 329
but why?
Zip.pm code
sub setErrorHandler (<) {
my $errorHandler = shift;
$errorHandler = \<Carp::carp unless defined($errorHandler);
my $oldErrorHandler = $Archive::Zip::ErrorHandler;
$Archive::Zip::ErrorHandler = $errorHandler;
return $oldErrorHandler;
}
######################################################################
# Private utility functions (not methods).
sub _printError {
my $string = join ( ' ', @_, "\n" );
my $oldCarpLevel = $Carp::CarpLevel;
$Carp::CarpLevel += 2;
<{$ErrorHandler} ($string); <-------- this line is failing
$Carp::CarpLevel = $oldCarpLevel;