Here, without all the extraneous modules, is simple example code. You're not using the Archive::Zip module properly.
#!/usr/bin/perl use strict; use warnings; use File::Spec::Functions qw'catdir catfile'; use Archive::ZIP qw':ERROR_CODES :CONSTANTS'; # here's an example @chunks array my @chunks = qw(file1.txt file2.txt file3.txt); #example output file name: output.zip in HomeDir my $zip_file = catfile($ENV{HOME},'output.zip'); my $zip = Archive::Zip->new(); foreach my $file (@chunks) { my $member = $zip->addFile($file); #add fil +e $member->desiredCompressionMethod( COMPRESSION_DEFLATED ); #compres +s file } #write ZIP file to disk my $status = $zip->writeToFileNamed($zip_file); die "Unable to write to file '$zip_file' if $status != AZ_OK; #error c +heck
Note that I never open my own file handle, the module takes care of all that for me.
In reply to Re: Zipping Files
by radiantmatrix
in thread Zipping Files
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |