cbullard has asked for the wisdom of the Perl Monks concerning the following question:
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"; }
How can I access the list of files inside the zip archive and the stats for them (size, mod date, etc)?
Thank you!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Listing contents and stats of ZIP archive contents
by ww (Archbishop) on May 13, 2013 at 22:22 UTC | |
|
Re: Listing contents and stats of ZIP archive contents
by NetWallah (Canon) on May 14, 2013 at 04:10 UTC | |
|
Re: Listing contents and stats of ZIP archive contents
by LanX (Saint) on May 13, 2013 at 22:00 UTC |