in reply to Reading data from ZIP data in a File::Temp filehandle problem
I added my $tmp = IO::File->new( 'test1.zip', 'r' ); straight from the Archive::Zip documentation for readFromFileHandle() at cpan to open a filehandle and it works. I tried first with open() and got an error from Archive::Zip that the file must be seekable. Then in the documentation it mentions it must be seekable. I didn't realize there was a difference.
use strict; use warnings; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); use Data::Dumper; my $tmp = IO::File->new( 'test1.zip', 'r' ); my $zip = Archive::Zip->new(); my $zip_err = $zip->readFromFileHandle( $tmp ); unless ($zip_err == AZ_OK ) { die "Archive::Zip read error on filehandle: $zip_err\n"; } foreach my $member ($zip->members()) { my $fileName = $member->fileName(); print "fileName = $fileName\n"; my $content = $member->contents(); print "contents $fileName = ".Dumper($content); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading data from ZIP data in a File::Temp filehandle problem
by drewhead (Beadle) on Sep 15, 2011 at 12:51 UTC | |
by Lotus1 (Vicar) on Sep 15, 2011 at 13:21 UTC |