Chap Harrison wrote:
Well, I suppose I've missed a subtlety along the way here. I have two
directories:
/path/to/existing/directory/foo/
/path/to/existing/directory/bar/
And I want to archive these two directories into a zip file named
archive.zip.
Here's what I did, using the synopsis of Archive::Zip in CPAN as a
guide:
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
my $zip = Archive::Zip->new();
my $super_path = "/path/to/existing/directory";
my $dir_member;
$dir_member = $zip->addDirectory( "$super_path/foo/" ); # what should I do
with $dir_member? anything?
$dir_member = $zip->addDirectory( "$super_path/bar/" );
# Save the Zip file
unless ( $zip->writeToFileNamed("$super_path/archive.zip") == AZ_OK ) {
die 'write error';
}
After executing, the archive.zip file contains basically just the two
directory names. (source directories foo/ and bar/ are definitely
populated~)
What boneheaded mistake have I made this time? I suspect I should do
something with $dir_member, but it's not apparent to me.
You should have read the section "Zip Archive Tree operations":
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
my $zip = Archive::Zip->new();
my $super_path = '/path/to/existing/directory';
$zip->addTree( "$super_path/foo", 'foo' );
$zip->addTree( "$super_path/bar", 'bar' );
$zip->writeToFileNamed( "$super_path/archive.zip" );
John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity. -- Damian Conway
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/