On 09/14/2006 09:20 AM, Derek B. Smith wrote:
[...]
sub zipit {
##-- Add all readable files below $oldir --##
##-- and write them into a file. --##
my $zip = Archive::Zip->new();
my $entry = $zip->addDirectory ("$oldir/$word/")
or die "Failed to add file for archive zip $!";
$entry->desiredCompressionLevel(9);
my @entries = $entry->membersMatching('log.*');
Huh?
MembersMatching should return an empty list because the new
zip file (object) is empty, and that means that the directory
entry ($entry) is also empty.
$zip->writeToFileNamed(@entries)
Huh?
WriteToFileNamed is supposed to take a simple filename
(string) argument--not an array. Stringification of that array
would have the effect you complained about.
or die "Failed to write zip file $!" if $zip !=
AZ_OK;
}
[...]
Try something like this (but season to taste):
#!/usr/bin/perl
use strict;
use warnings;
use File::Slurp;
use Archive::Zip;
use File::Spec::Functions;
my %subdir_for = (
'fawn-hall' => 41,
'gary-hart' => 59,
'monkey-business' => 81,
);
my $srcdir = catfile($ENV{HOME}, qw(tmp bp));
my $arcfile = catfile($ENV{HOME}, qw(tmp myfile.zip));
my $zip = Archive::Zip->new();
for my $file (keys %subdir_for) {
$zip->addDirectory($subdir_for{$file});
my $source = catfile($srcdir, $file);
my $target = catfile($subdir_for{$file},$file);
$zip->addFile($source,$target);
}
$zip->writeToFileNamed($arcfile);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>