I have a code which archives the files and create the corresponding zip files with same name. But this piece of code works on some folder correctly , whereas on other it gives error. "Can't call method "desiredCompressionlevel" on an undefined value at C:/Perl64/Archive/Zip/Archive.pm line 261"
sub addFile { my $self = shift; my ( $fileName, $newName, $compressionLevel ); if ( ref( $_[0] ) eq 'HASH' ) { $fileName = $_[0]->{filename}; $newName = $_[0]->{zipName}; $compressionLevel = $_[0]->{compressionLevel}; } else { ( $fileName, $newName, $compressionLevel ) = @_; } if ( $^O eq 'MSWin32' && $Archive::Zip::UNICODE ) { $fileName = Win32::GetANSIPathName($fileName); } my $newMember = $self->ZIPMEMBERCLASS->newFromFile( $fileName, $ne +wName ); $newMember->desiredCompressionLevel($compressionLevel); if ( $self->{'storeSymbolicLink'} && -l $fileName ) { my $newMember = $self->ZIPMEMBERCLASS->newFromString(readlink +$fileName, $newName); # For symbolic links, External File Attribute is set to 0xA1FF +0000 by Info-ZIP $newMember->{'externalFileAttributes'} = 0xA1FF0000; $self->addMember($newMember); } else { $self->addMember($newMember); } if ( $^O eq 'MSWin32' && $Archive::Zip::UNICODE ) { $newMember->{'fileName'} = encode_utf8( Win32::GetLongPathName +($fileName) ); } return $newMember; }
In reply to Perl Archiving Process error by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |