Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   Archive Zip Compression Level (http://www.go4expert.com/forums/archive-zip-compression-level-t28172/)

TedH 11Apr2012 17:42

Archive Zip Compression Level
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.

## works okay
my $zip = Archive::Zip->new();

## I have tried this, but it errors
## (Can't call method "desiredCompressionLevel"
##  without a package or object reference)
my $zip = Archive::Zip->new();

Hope someone can help please - Thanks

pradeep 23Apr2012 11:23

Re: Archive Zip Compression Level

TedH 23Apr2012 13:40

Re: Archive Zip Compression Level
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

peterB 14Nov2012 16:59

Re: Archive Zip Compression Level
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();

TedH 14Nov2012 23:51

Re: Archive Zip Compression Level
I'd forgotten all about this...
Thanks, I'll give that a try.

peterB 15Nov2012 14:59

Re: Archive Zip Compression Level
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. :-)

All times are GMT +5.5. The time now is 17:25.