I am trying to list out the names and stats of the contents of a ZIP file. I've tried working with both Archive::Extract and IO::Uncompress with no success. I've even tried using this code straight from the PerlMonks Archives:

#! c:\perl\bin\perl use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); if (scalar(@ARGV) < 2){die "Zip.pl\nAuthor:Include\nUsage: zip.pl <c=c +reate, x=extract> <filename> <files>\n";}; my $opt = shift(@ARGV); my $ofile = shift(@ARGV); # extract a zip file if($opt=~/x/i){ print "Zip.pl\nAuthor:Include\n"; print "Extracting $ofile...\n"; $zip = Archive::Zip->new(); die 'Error reading zip file.' if $zip->read( $ofile ) != AZ_OK; my @members = $zip->members(); foreach $element(@members) { print "$element\n"; $zip->extractMember($element); } print "Done!\n"; }

but all I get for output is:
$ ./ziptest.pl X zipbatch/testzip.zip testout.txt
Zip.pl
Author:Include
Extracting zipbatch/testzip.zip...
Archive::Zip::ZipFileMember=HASH(0x1e68844)
Archive::Zip::ZipFileMember=HASH(0x1e68e14)
Archive::Zip::ZipFileMember=HASH(0x1e68fe4)
Archive::Zip::ZipFileMember=HASH(0x1a4890c)
Done!

How can I access the list of files inside the zip archive and the stats for them (size, mod date, etc)?

Thank you!

In reply to Listing contents and stats of ZIP archive contents by cbullard

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.