sirhalos has asked for the wisdom of the Perl Monks concerning the following question:
Currently have a subroutine that works that gathers filesize information of zip files. I'm looking to turn this into a more pure perl solution for speed purproses (I need to do this over millions of files).
I looked in Archive::Zip and Archive::Unzip and wasn't really finding anything. For tarballs I was able to do this with Archive::Tar->list_archive for tarballs.
Current working code
sub CollectZip { my ($location) = shift; my @zipListData = `unzip -l \'$location\'`; chomp @zipListData; ### Get rid of the first 3 rows and last 2 rows shift(@zipListData); shift(@zipListData); shift(@zipListData); pop(@zipListData); pop(@zipListData); my %filesData; foreach my $zipData (@zipListData) { $zipData =~ tr/ //s; my @zipData = split(/ /, $zipData); my ($zipFilesize) = $zipData[1]; my ($zipFilename) = $zipData[4]; $filesData{$zipFilename} = $zipFilesize; } print Dumper \%filesData; return %filesData; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unzip -l replacement
by marinersk (Priest) on Mar 10, 2015 at 19:49 UTC | |
by sirhalos (Sexton) on Mar 11, 2015 at 12:50 UTC | |
by marinersk (Priest) on Mar 11, 2015 at 14:35 UTC |