0

I'm using a Perl script to modify some files inside a .tar, and the directory structure inside the resulting .tar disappears. Eliminating more and more code I've come as far as all that's required to reproduce this is

my $data_tar = Archive::Tar->new('data.tar');
$data_tar->write('modified_data.tar');

Both .tar-files have all the files, however the indication of what directories the files and subdirectories were located in are lost.

I've looked through the docs and src for Archive::Tar but I really don't understand what's going on.

I'm using perl 5.10.0 on win32, tar 1.12 and Archive::Tar 1.54. I examined the .tar-files in an editor and the data.tar contains dir/ and dir/file.txt, but in the modified_data.tar they show up as dir and file.txt so my original tar seems ok.

Anyone of you that have seen this before or have any ideas?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Ledhund
  • 1,228
  • 10
  • 24

2 Answers2

3
C:\Temp> perl -v

This is perl, v5.10.1 built for MSWin32-x86-multi-thread
(with 2 registered patches, see perl -V for more detail)
C:\Temp> perl -MArchive::Tar -e "print $Archive::Tar::VERSION"
1.52

Cannot replicate using data.tar created with:

C:\Temp> tar --version
tar (GNU tar) 1.21

As @~quack notes, the docs state:

Note that GNU tar earlier than version 1.14 does not cope well with the POSIX header prefix. If you use such a version, consider setting the $Archive::Tar::DO_NOT_USE_PREFIX variable to true.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
  • 4
    from the POD (regarding GNU tar versions): "Note that GNU tar earlier than version 1.14 does not cope well with the POSIX header prefix. If you use such a version, consider setting the $Archive::Tar::DO_NOT_USE_PREFIX variable to true." – quack quixote Oct 09 '09 at 15:48
  • @~quack: I didn't really know what a posix header was so I guess I skipped past that part. This is exactly what I needed! – Ledhund Oct 09 '09 at 16:02
  • @quack: I'm surprised you didn't just make that an answer, since it seems to be the problem being run into. – Powerlord Oct 09 '09 at 19:18
  • @R. Bemrose I think @~quack realized that because I originally provided the GNU tar version in my post and was nice about it. – Sinan Ünür Oct 10 '09 at 00:27
  • @R. Bemrose didn't know that was the answer at the time :) – quack quixote Oct 10 '09 at 00:59
0

I tried your script but could not reproduce the problem (on FreeBSD using Perl 5.10).