in reply to Decoding .z and .gz files
.Z files (uppercase) are compressed using a simple LZW algorithm. You can unpack them with Compress::LZW or Compress::LZF.
update: oops, it says in the documentation that Compress::LZW does not support .Z files..
use Compress::LZF ':compress'; my $file = shift; open my $fh, '<', $file or die "Cannot open $file for input: $!\n"; local $/ = undef; my $decompressed = decompress(<$fh>);
Update: hmmm, I don't actually have any .Z files around, so I made one, and the above code fails to decompress it, as does Compress::Zlib's uncompress function. Sigh.
Do you have a decompress binary lying around? Or you don't and you really have to do this in Perl? Because if you did, it would probably be much faster to pay the system call and let the binary do the decompression.
• another intruder with the mooring in the heart of the Perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Decoding .z and .gz files
by blackadder (Hermit) on Mar 26, 2007 at 12:15 UTC | |
by jettero (Monsignor) on Mar 26, 2007 at 12:34 UTC | |
by blackadder (Hermit) on Mar 26, 2007 at 13:13 UTC | |
by almut (Canon) on Mar 26, 2007 at 14:52 UTC |