unzip with Archive::Zip ?

G

Geoff Cox

Hello

I have just read that I cannot use Archive::Zip to unzip a file is
this correct? If not, how do I carry out the unzip process?

Thanks

Geoff
 
H

Helgi Briem

I have just read that I cannot use Archive::Zip to unzip a file is
this correct? If not, how do I carry out the unzip process?

No, that is absolutely incorrect. Here is an example:

#!perl
use warnings;
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );

my $dir = 'C:/temp';
my $zipfile = 'test.zip';

my $zip = Archive::Zip->new();
chdir $dir or die "Cannot chdir $dir:$!\n";
die "Error reading $zipfile:$!" unless $zip->read( "$dir/$zipfile" )
== AZ_OK;
$zip->extractTree();
__END__
 
G

Geoff Cox

#!perl
use warnings;
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );

my $dir = 'C:/temp';
my $zipfile = 'test.zip';

my $zip = Archive::Zip->new();
chdir $dir or die "Cannot chdir $dir:$!\n";
die "Error reading $zipfile:$!" unless $zip->read( "$dir/$zipfile" )
== AZ_OK;
$zip->extractTree();

Helgi

many thanks for the above - nearly there but when I run it (Perl 5.8.0
and Windows 98 (SE) I get an error message

"can't locate object method "extractTree" with package
Archive::Zip::Archive"

any ideas?

Geoff
 
H

Helgi Briem

many thanks for the above - nearly there but when I run it (Perl 5.8.0
and Windows 98 (SE) I get an error message

"can't locate object method "extractTree" with package
Archive::Zip::Archive"

any ideas?

No. It works here for me (Win2K and Activeperl 5.8.0).

Just tested it on one of my Linux boxes, RH9 and Perl 5.8,
worked perfectly there (changed name of zipfile of course).
 
G

Geoff Cox

No. It works here for me (Win2K and Activeperl 5.8.0).

Just tested it on one of my Linux boxes, RH9 and Perl 5.8,
worked perfectly there (changed name of zipfile of course).

Helgi

I have just posted a separate message re the fact that when I upgraded
to ActiveState Perl 5.8.2 build 808 I get following error messages!!
Any idea why? Appears to refer to the use Archive::Zip line...

Geoff


D:\a-keep8\perl\progs>perl unzip3.pl
Can't locate loadable object for module IO in @INC (@INC contains:
C:/Perl/lib
:/Perl/site/lib .) at C:/Perl/lib/IO/Handle.pm line 260
Compilation failed in require at C:/Perl/lib/IO/Handle.pm line 260.
BEGIN failed--compilation aborted at C:/Perl/lib/IO/Handle.pm line
260.
Compilation failed in require at C:/Perl/lib/IO/Seekable.pm line 101.
BEGIN failed--compilation aborted at C:/Perl/lib/IO/Seekable.pm line
101.
Compilation failed in require at C:/Perl/lib/IO/File.pm line 117.
BEGIN failed--compilation aborted at C:/Perl/lib/IO/File.pm line 117.
Compilation failed in require at C:/Perl/site/lib/Archive/Zip.pm line
22.
BEGIN failed--compilation aborted at C:/Perl/site/lib/Archive/Zip.pm
line 22.
Compilation failed in require at unzip3.pl line 4.
BEGIN failed--compilation aborted at unzip3.pl line 4.
 
G

Geoff Cox

On Fri, 09 Jan 2004 10:34:03 +0000, Helgi Briem

Helgi

I am still having problems! I wish to move through some
sub-directories using Find::File and extract all the zip files - all
of which have only 1 file in them..

Using following code I get error following messages


d:\files\perl unzip4.pl
format error: can't find EOCD signature at unzip4.pl line 17
Error reading chapter4--qualitiies.doc: at unzip4.pl line 13.


#!perl
use warnings;
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
use File::Find;

my $dir = 'd:/a-keep8/perl/progs/btec-first';

find sub {
my $name = $_;
return if -d;
my $zip = Archive::Zip->new();
13 die "Error reading $name:$!" unless $zip->read("$name") == AZ_OK;
$zip->extractTree();


17 }, $dir;

if you can see my mistakes please help me!

Cheers

Geoff
 
G

Geoff Cox

Sure wish I could help you (and me). I get the exact same
error as you on my Win2000 with Perl 5.8.0.

Mike

not certain that this did the trick - but the above error message has
gone away!

I upgraded to the ActiveState latest Perl, v5.8.2 build 808 ... NB if
you do this make sure you uninstall the earlier version first as not
doing so gave me further error messages and in fact there is a warning
re this somewhere!

Cheers

Geoff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top