Dear Monks

I am trying to decode compressed files mainly of .gz and .z types!

To start off with I wrote this scripts to handle .gz file;
#! c:/perl/bin/perl.exe # By me- March 2007 use strict; use Archive::Tar; #use Archive::Zip; system(cls); my $tar = Archive::Tar->new(); opendir (DIR, $ARGV[0]) || die "\nHey, gimme a path to work with pleas +e!\n"; my @dirs = readdir (DIR); unlink ("$ARGV[0]\\modinfo.txt"); foreach my $dir (@dirs) { next if ($dir eq '.' || $dir eq '..'); $tar->read("$ARGV[0]\\$dir", 1); @_ = $tar->list_files(); for my $modinfo (@_) { next unless ($modinfo =~ /modinfo.txt/); $tar->extract_file( $modinfo, "$ARGV[0]\\modinfo.txt"); open(FILE,"$ARGV[0]\\modinfo.txt") || die "D'oh: need a lot of + help here!"; chomp (my @stuff = <FILE>); for my $line (@stuff) { next unless ($line =~ /vx/); $line =~ s/^\s+//; $line =~ /(\w+)\s+(\w+)\s+(\w+)\s+(\d+)\s+(\d+)\s+(\w+)\s+ +\((.+)\)$/; printf "%s, %s,%s,%s,%s,%s,%s,(%s)\n",$dir,$1,$2,$3,$4,$5, +$6,$7; } } }
which works fine on the ".gz" but it can't handle ".z" files!

I tried Archive::Zip to no avail!

I began to look around here for posts that have delt with similar issues. The advice I got (tho it seems) that I should be using Comprees::Zlib. So I tried the following bit of code just to test, however its didn't work (i.e. it returned noise - exaclty similar to opening any binary file with a basic text editor)!
#! c:/perl/bin/perl.exe use strict; use Compress::Zlib ; my $gz = gzopen("c:\\eee.tar.z", "rb") || die "Cannot open c:\\eee.tar +.z: $gzerrno\n" ; while ($gz->gzreadline($_) > 0) { print ; }
Can someone please help me out or shed a light on what I need to do in order to extract files from .z files?

Thanks
Blackadder

In reply to Decoding .z and .gz files by blackadder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.