#!/opt/perl/bin/perl
use warnings;
use strict;
use diagnostics;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
MAIN: {
my $zd = 'foobar';
my $zip = Archive::Zip->new();
my $d = $zip->addDirectory( $zd );
my $f = $zip->addString( 'this is a test', "$zd/foo.txt" );
$f->desiredCompressionMethod( COMPRESSION_DEFLATED );
$f = $zip->addString( 'of the emergency broadcast system', "$zd/ba
+r.txt" );
$f->desiredCompressionMethod( COMPRESSION_DEFLATED );
unless ( $zip->writeToFileNamed("$zd.zip") == AZ_OK ) {
die 'write error';
}
exit 0;
}
$ unzip -l foobar.zip
Archive: foobar.zip
Length Date Time Name
-------- ---- ---- ----
0 09-28-12 11:18 foobar/
14 09-28-12 11:18 foobar/foo.txt
33 09-28-12 11:18 foobar/bar.txt
-------- -------
47 3 files
$
|