diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-07-31 18:59:09 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-07-31 18:59:09 +0000 |
commit | 42c8b23669eac442a303190dad44d78cea63cf59 (patch) | |
tree | 1cc49a1a1813bd802988e88058f353a4e0a23514 /examples/writeScalar2.pl | |
download | Archive-Zip-tarball-master.tar.gz |
Archive-Zip-1.49HEADArchive-Zip-1.49master
Diffstat (limited to 'examples/writeScalar2.pl')
-rw-r--r-- | examples/writeScalar2.pl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/examples/writeScalar2.pl b/examples/writeScalar2.pl new file mode 100644 index 0000000..dab44c5 --- /dev/null +++ b/examples/writeScalar2.pl @@ -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(); + |