in reply to Re^2: How do i change the file names while untar?
in thread How do i change the file names while untar?

Try omitting the compression flag since you are dealing with an uncompressed tarball, and call new as the constructor,

my $tar = Archive::Tar->new('test.tar') or die $!;

That will make $tar an Archive::Tar object whose methods will be found.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^4: How do i change the file names while untar?
by perl_99_monk (Novice) on Sep 29, 2005 at 18:40 UTC
    Zaxo, I tried it and the split path does not work either on unix .

      my $tar = Archive::Tar->new('deploy.tar', 1) or die $!;
     $tar->rename($_, changepath($_)) for $tar->list_files; $tar->extract;
      sub changepath { chomp; my $path = $_;
      my ($volume, $directories, $file) = File::Spec->splitpath($path);
      my $dir = File::Spec->catpath($directories, '');
    $_=$dir; }
    THe same code works fine on win 32. I am getting files from windows into unix and then trying to do these operations. Do you think it would be better to rename while tarring itself on windows box? Is that possible? Thanks
Re^4: How do i change the file names while untar?
by perl_99_monk (Novice) on Sep 29, 2005 at 15:23 UTC
    Zaxo, I tried it and the split path does not work either on unix . my $tar = Archive::Tar->new('deploy.tar', 1) or die $!; $tar->rename($_, changepath($_)) for $tar->list_files; $tar->extract; sub changepath { chomp; my $path = $_; my ($volume, $directories, $file) = File::Spec->splitpath($path); my $dir = File::Spec->catpath($directories, ''); $_=$dir; } THe same code works fine on win 32. I am getting files from windows into unix and then trying to do these operations. Do you think it would be better to rename while tarring itself on windows box? Is that possible? Thanks