| [reply] |
The other monks are correct in suggesting that the best way to do this is via CPAN, but if for whatever reason you can't install a module, this is how you'd do this in a shell:
[jon@nooky jon]$ zcat foo.tar.Z | tar xvf
BlueLines
Disclaimer: This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary. | [reply] [d/l] |
I believe you can use Compress::Zlib to do this. There's a section in its perldoc about "Accessing Zip Files" | [reply] |
I incorporated BlueLine's suggestion into an existing subroutine I use to read tar.gz files.
my $gunzip = "/usr/bin/gunzip -c"; # Location of gunzip;
my $Zopen = "/bin/zcat $FILENAME | /bin/tar -xvf";
my $READ;
sub FancyFopen {
my ($FILENAME) = @_;
# my $Fhandle= new FileHandle;
if (-s $FILENAME){ $READ="/bin/cat";}
elsif(-s $FILENAME.".gz"){
$READ=$GUNZIP;
$FILENAME=$FILENAME.".gz";}
elsif (-s $FILENAME."tar.Z"){
$READ=$Zopen;
$FILENAME=$FILENAME."tar.Z";}
else {
print "Cannot open \"$FILENAME\*\" for gunzip input\n";
}
open(Fhandle,"$READ $FILENAME |") ||
print "Cannot open \"$FILENAME\" for input\n";
return Fhandle;
}
HTH,
Steve | [reply] [d/l] |