Hey monks,

I'm trying to use Archive::Zip to compress some text files for clients to download, but they appear to be corrupted. I get an error message, and only the first file in the .zip is extracted (regardless of which file that is).

I can see all the files when I look at the compressed file contents.

I am using Centos 5.2 x86_64 with perl 5.8.8 and Archive::Zip 1.30. Here is the error message I get:
warning [/home/student1/Desktop/compounds1310483480.zip]: 104 extra b +ytes at beginning or within zipfile (attempting to process anyway) file #1: bad zipfile offset (local header sig): 104 (attempting to re-compensate) bad CRC 50b35a73 (should be 00000000) file #2: bad zipfile offset (local header sig): 405 (attempting to re-compensate) file #2: bad zipfile offset (local header sig): 405 file #3: bad zipfile offset (local header sig): 1020 file #4: bad zipfile offset (local header sig): 1552

The errors I get when attempting to extract the files in Windows/OSX are 'corrupt/invalid'.

Here is the code I use to create the zip file:

foreach my $memberName (@MOL2_files) { if (-d $memberName ) { print $log "Adding $memberName\n"; warn (print $log "Error adding directory $memberName\n") if $zip->addTree( $memberName, $memberName) != AZ_OK; } else { print $log "Adding $memberName\n"; $zip->addFile( "/www/mol2/$memberName", "compounds".$time."/". +$memberName ) or warn (print $log "Error adding file $memberName\n"); } } open my $fh, ">>", $fullpath or die $!; print $log "Write Error.\n" if $zip->writeToFileNamed( $fh ) != AZ_OK;

Has anyone seen this problem before and know how to fix it? Or does anyone know of a different module I can use to perform the same function?

Thanks, Tom


In reply to Archive::Zip - zip files are corrupted or invalid by tomdbs98

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.