in reply to Decoding .z and .gz files

According to http://search.cpan.org/dist/Compress-Zlib/pod/FAQ.pod#Accessing_.tar.Z_files, you have to use an external binary:
The Archive::Tar module can optionally use Compress::Zlib (via the IO::Zlib module) to access tar files that have been compressed with gzip. Unfortunately tar files compressed with the Unix compress utility cannot be read by Compress::Zlib and so cannot be directly accesses by Archive::Tar.

If the uncompress or gunzip programs are available, you can use one of these workarounds to read .tar.Z files from Archive::Tar

Replies are listed 'Best First'.
Re^2: Decoding .z and .gz files
by blackadder (Hermit) on Mar 27, 2007 at 08:42 UTC
    IT WORKED,....Thanks for all the replies

    I used "Gunzip.exe" on the .z files!

    Here is the full code
    #! c:/perl/bin/perl.exe # # By a PerlMonk # use strict; use Archive::Tar; my $tar = Archive::Tar->new(); system(cls); opendir (DIR, $ARGV[0]) || die "\nInvalid path $ARGV[0]!\n"; my @path = readdir (DIR); for my $comp_file (@path) { next if ($comp_file eq '.' || $comp_file eq '..'); my $temp_path = "$ARGV[0]\\$comp_file"; `gunzip.exe $temp_path` if ($comp_file =~ /\.z$/); my $tar = Archive::Tar->new(); $tar->read("$temp_path", 1); @_ = $tar->list_files(); for my $compressed (@_) { next unless ($compressed =~ /modinfo.txt/); $tar->extract_file( $compressed, "$ARGV[0]\\extracted_modinfo. +txt"); open(FILE,"$ARGV[0]\\extracted_modinfo.txt") || warn "$!: Cann +ot access temp file\n"; chomp (my @vx_data = <FILE>); for my $vx (@vx_data) { next unless ($vx =~ /vx/); $vx =~ s/^\s+//; $vx =~ /(\w+)\s+(\w+)\s+(\w+)\s+(\d+)\s+(\d+)\s+(\w+)\s+\( +(.+)\)$/; printf "%s, %s,%s,%s,%s,%s,%s,(%s)\n",$comp_file,$1,$2,$3, +$4,$5,$6,$7; } close (FILE); unlink ("$ARGV[0]\\extracted_modinfo.txt"); } }
    Thanks again "feel an urge for a donation now! :-)"
    Blackadder