Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Archiving Process error
by Eily (Monsignor) on Jul 12, 2016 at 12:48 UTC | |
by choroba (Cardinal) on Jul 12, 2016 at 13:14 UTC | |
by Eily (Monsignor) on Jul 12, 2016 at 13:24 UTC | |
|
Re: Perl Archiving Process error
by GotToBTru (Prior) on Jul 12, 2016 at 12:46 UTC |