Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libarchive-zip-perl / libarchive-zip-perl-1.18 / examples / writeScalar2.pl
diff --git a/dev/i386/libarchive-zip-perl/libarchive-zip-perl-1.18/examples/writeScalar2.pl b/dev/i386/libarchive-zip-perl/libarchive-zip-perl-1.18/examples/writeScalar2.pl
new file mode 100644 (file)
index 0000000..407c928
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/perl -w
+use strict;
+use Archive::Zip qw(:CONSTANTS :ERROR_CODES);
+use IO::String;
+use IO::File;
+
+# test writing to a scalar
+my $zipContents = '';
+my $SH = IO::String->new($zipContents);
+
+my $zip = Archive::Zip->new();
+my $member = $zip->addString('a' x 300, 'bunchOfAs.txt');
+$member->desiredCompressionMethod(COMPRESSION_DEFLATED);
+$member = $zip->addString('b' x 300, 'bunchOfBs.txt');
+$member->desiredCompressionMethod(COMPRESSION_DEFLATED);
+my $status = $zip->writeToFileHandle( $SH );
+
+my $file = IO::File->new('test.zip', 'w');
+binmode($file);
+$file->print($zipContents);
+$file->close();
+