Re: Untaring with perl
by halley (Prior) on Aug 24, 2005 at 17:28 UTC
|
The ".tgz" is an abbreviated file extension indicating ".tar.gz" which is a tarball that was subsequently compressed with gzip. (Of course, a filename does not actually prove what is in the file, it could be a spreadsheet and not a tarball at all, for all we know.) According to Archive::Tar, the module WILL deal with this but only if you have IO::Zlib also installed.
-- [ e d @ h a l l e y . c c ]
| [reply] |
|
|
Its installed, thanks for your reply.
| [reply] |
Re: Untaring with perl
by liverpole (Monsignor) on Aug 24, 2005 at 17:24 UTC
|
How about just doing ...?
#!/usr/bin/perl -w
my $file = "/tmp/anything.tgz";
system("tar -vxzf $file");
| [reply] [d/l] |
Re: Untaring with perl
by gryphon (Abbot) on Aug 24, 2005 at 17:30 UTC
|
Greetings mrbbq,
This is untested, and I only just now tossed it together, but is this what you're asking for?
use Archive::Tar;
my $tar = Archive::Tar->new;
chdir '/tmp' or die $!;
$tar->read('anything.tgz', 1, { 'extract' => 1 } );
I'd rather not have to chdir; instead, I'd like to tell Archive::Tar where to extract the files. How to do that is probably in the POD somewhere.
gryphon
Whitepages.com Development Manager (DSMS)
code('Perl') || die;
| [reply] [d/l] |
|
|
Works perfect, thank you.
| [reply] |
|
|
could anything.tgz be a variable?
$tar->read('$tar_file",1, { 'extract' => 1 });
I could not get it to work passing a variable...ideas?
thanks
| [reply] |
|
|
use strict;
my $tar_file = 'anything.tgz';
$tar->read( $tar_file, 1, { 'extract' => 1 } );
gryphon
Whitepages.com Development Manager (DSMS)
code('Perl') || die;
| [reply] [d/l] |
Re: Untaring with perl
by derby (Abbot) on Aug 24, 2005 at 17:29 UTC
|
use Archive::Tar;
my $tar = Archive::Tar->new;
$tar->read('origin.tgz',1);
$tar->extract();
What seems to be the problem?
| [reply] [d/l] |
|
|
Yeah I know...I read it, looked at it couldnt get it to work? Thanks for your reply.
| [reply] |
Re: Untaring with perl
by ait (Hermit) on Aug 24, 2005 at 17:40 UTC
|
perldoc -f exec
perldoc -f system
my favorite: you can execute a shell command by using the backtick assigning the result to a variable:
my $hoo = `tar xvfz /tmp/foo`;
(note that in the example you will not get the actual contents of the tar, you will only get the listing that the tar command outputs)
--
Alejandro
| [reply] |