Fellow Monks,
I am on windows 2000, using activestate perl. I have the following piece of code. It simply grabs a load of text files from a directory and zips them up for archiving. It works well for a small number of text files, but I've got 3,500 plus text files, and it's taking anything up to an hour to complete. Any hints on how to speed this thing up? (The resulting zip file has to be compatible with winzip).
#!/usr/bin/perl
use warnings;
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS);
my $date = "text files";
my $zip = Archive::Zip->new();
opendir DIR, $date;
my @Filelist = grep { /.txt$/ } readdir DIR;
foreach my $file(@Filelist){
my $member = $zip->addFile("$date\\$file");
die 'Error writing file' if $zip->writeToFileNamed("$date.zip"
+) != AZ_OK;
}
print "Finished\n"
Thanks in advance,
Jonathan.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.