Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

zipped and tar files.

by ant (Scribe)
on Oct 06, 2006 at 15:45 UTC ( #576698=perlquestion: print w/replies, xml ) Need Help??

ant has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

Once again I come looking for answers, so thanks in advance to replies.

I have file named UPatchCAAGAIAE_B.tar.Z, which I'm tring to use Archive::Zip on. I know that the code is correct as it unzips other files fine.
my $extract_file = $start_path . $env . "\\mrf" . $mrf_num . "\\$item" +; my $zip = Archive::Zip->new(); if($zip->read($extract_file) != AZ_OK) { die "Unable to decompress zip file '$extract_file'"; }
However when I try to unzip this, it falls over, see error message below.

Any suggestions??

Thanks

\UPatchCAAGAIAE_B.tar.Z format error: can't find EOCD signature Archive::Zip::Archive::_findEndOfCentralDirectory('Archive::Zi +p::Archive=HASH(0x1b6bd68)', 'IO::File=GLOB(0x1b6be64)') Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archi +ve=HASH(0x1b6bd68)', 'IO::File=GLOB(0x1b6be64)', 'R:\Rele Archive::Zip::Archive::read('Archive::Zip::Archive=HASH(0x1b6b +d68)', 'R:\Relfsdfdment\pdsfsdhes\OdsfW\mrf15009\UPatc

Replies are listed 'Best First'.
Re: zipped and tar files.
by Fletch (Bishop) on Oct 06, 2006 at 15:49 UTC

    You're trying to use Archive::Zip which handles PKZip-format archives to extract files from a compress'd TAR file; use the right tool for the job instead.

    Update: I'd say try Archive::Extract which tries to transparently do the right thing, but it doesn't appear as though that handles tar.Z files (even though treating them like tar.gz ones should work perfectly well).

Re: zipped and tar files.
by grep (Monsignor) on Oct 06, 2006 at 17:09 UTC
    as Fletch pointed out a '.Z' extention generally denotes a file that was compressed with the utility compress. Unfortunately modules that use Compress::Zlib will not work on .Z compress files (The compress utility is old and bascially deprecated). Your best option comes from the Compress:Zlib FAQ

    Best Option:
    If you have a newer version of the gzip (GNU zip) utility.

    use Archive::Tar; # using the cli utility gunzip # -c causes the file to be 'cat'ed open F, "gunzip -c $filename |"; my $tar = Archive::Tar->new(*F);

    Other Option:
    Get the ncompress utility and compile. Then you can:

    use Archive::Tar; # using the cli utility compress # -c causes the file to be 'cat'ed open F, "uncompress -c $filename |"; # or use # open F, "zcat -c $filename |"; my $tar = Archive::Tar->new(*F);

    Archive::TarGzip does not seem to support .Z compressed files either.



    grep
    One dead unjugged rabbit fish later
Re: zipped and tar files.
by madbombX (Hermit) on Oct 06, 2006 at 16:44 UTC
    I would recommend combining a few CPAN modules to get the desired result. Start out with File::Type to determine the file type.
    my $ft = File::Type->new(); my $file_type = $ft->checktype_filename($file);
    Or alternatively, you can check out Archive::TarGzip and mix that with the use of Archive::Zip based on the output of File::Type.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://576698]
Approved by wfsp
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2023-01-30 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?