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.

<radiant.matrix>
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

In reply to Re: Zipping Files by radiantmatrix
in thread Zipping Files by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.