K
Kevin
perl, v5.8.3
Archive-Zip-1.13
How do I need to change the code given in the Archive::Zip examples
directory to make it work with perl 5.8? It works ok on machines with
5.6 and I'm assuming that it's a problem caused by changes in 5.8.
When I try to run the readScalar.pl code I get:
Read 20000 bytes
error: file not seekable
Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x92ebd98)','IO::Scalar=GLOB(0x90de7d4)')
called at ./readScalar.pl line 20
(this is the code):
#!/usr/bin/perl -w
# Demonstrates reading a zip from an IO::Scalar
# $Revision: 1.4 $
use strict;
use Archive::Zip qwCONSTANTS :ERROR_CODES);
use IO::Scalar;
use IO::File;
# test reading from a scalar
my $file = IO::File->new('testin.zip', 'r');
my $zipContents;
binmode($file);
$file->read($zipContents, 20000);
$file->close();
printf "Read %d bytes\n", length($zipContents);
my $SH = IO::Scalar->new(\$zipContents);
my $zip = Archive::Zip->new();
$zip->readFromFileHandle( $SH );
my $member = $zip->addString('c' x 300, 'bunchOfCs.txt');
$member->desiredCompressionMethod(COMPRESSION_DEFLATED);
$member = $zip->addString('d' x 300, 'bunchOfDs.txt');
$member->desiredCompressionMethod(COMPRESSION_DEFLATED);
$zip->writeToFileNamed('test2.zip');
Archive-Zip-1.13
How do I need to change the code given in the Archive::Zip examples
directory to make it work with perl 5.8? It works ok on machines with
5.6 and I'm assuming that it's a problem caused by changes in 5.8.
When I try to run the readScalar.pl code I get:
Read 20000 bytes
error: file not seekable
Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x92ebd98)','IO::Scalar=GLOB(0x90de7d4)')
called at ./readScalar.pl line 20
(this is the code):
#!/usr/bin/perl -w
# Demonstrates reading a zip from an IO::Scalar
# $Revision: 1.4 $
use strict;
use Archive::Zip qwCONSTANTS :ERROR_CODES);
use IO::Scalar;
use IO::File;
# test reading from a scalar
my $file = IO::File->new('testin.zip', 'r');
my $zipContents;
binmode($file);
$file->read($zipContents, 20000);
$file->close();
printf "Read %d bytes\n", length($zipContents);
my $SH = IO::Scalar->new(\$zipContents);
my $zip = Archive::Zip->new();
$zip->readFromFileHandle( $SH );
my $member = $zip->addString('c' x 300, 'bunchOfCs.txt');
$member->desiredCompressionMethod(COMPRESSION_DEFLATED);
$member = $zip->addString('d' x 300, 'bunchOfDs.txt');
$member->desiredCompressionMethod(COMPRESSION_DEFLATED);
$zip->writeToFileNamed('test2.zip');