Hi, I use Archive::Zip to zip up directories for my backups. This works fine, but I would like to have better cmpression rather than the deault 6. Code: ## works okay my $zip = Archive::Zip->new(); $zip->addTree("path/to/directory"); $zip->writeToFileNamed("holdzips/$drty.zip"); ## I have tried this, but it errors ## (Can't call method "desiredCompressionLevel" ## without a package or object reference) my $zip = Archive::Zip->new(); $zip->addTree("path/to/directory")->desiredCompressionLevel(9); $zip->writeToFileNamed("holdzips/$drty.zip"); Hope someone can help please - Thanks
Looked at that before, but it refers to an individual file. I'm zipping up a folder with files and sub folders in, some of those folder have sub folders. However, it does compress them to about half size (the default) so will settle for that. Thanks anyways
There is no obvious waym but the following works for me $zipHandle->addTree( $tmpDir, '' ); # adding a directory as tree # set compression level for each member of the zip file map { $_->desiredCompressionLevel( $compressionLevel ) } $zipHandle->members();
Well, I had the same problem as you and found your question when I was looking for an answer. So I thought I'd provide my solution in case another person follows our steps.