Pergunta

I am trying to extract files from a tar file, but it can not extract all the file there are .ksh,.config,.txt,.param files. it is on;y extracting the .config file.

Could you please let me know how I can extract all files from that tar file. Also during extraction it is printing all the content of a file in command prompt I want to stop that.

Code I am using:

use Archive::Tar;

my $tar = Archive::Tar->new();
$tar->read('tar file name');

$tar->extract;
Foi útil?

Solução

Try this:

use Archive::Tar;

my $tar = Archive::Tar->new; # remove `()`

$tar->read('tar.tgz');
$tar->extract();

Outras dicas

First, I used perldoc Archive::Tar - it informed me that the correct syntax is

use Archive::Tar;
my $tar = Archive::Tar->new;

$tar->read('origin.tgz');
$tar->extract();

If extract() is called without parameters the entire contents of the archive are extracted (http://perldoc.perl.org/Archive/Tar.html)

use Archive::Tar;
my $tar = Archive::Tar->new;
$tar->extract();

Please check if your tar archive really contains these *.ksh, *.txt and *.params files. You may use:

$tar->contains_file( $filename )
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top