in reply to Archive::Tar fails to dereference and save symlinks?

It's not broken:). You're trying to print the error method, but it doesn't like that. This worked for me:
#!/usr/bin/perl -slw use strict; use Archive::Tar; use Data::Dumper::Concise; $Archive::Tar::FOLLOW_SYMLINK = 1; print $Archive::Tar::VERSION; my $t = Archive::Tar->new; $t->add_files('/root/Desktop/bar'); $t->write( 'baz.tgz', COMPRESS_GZIP ); $t->error(1); print "Done";

Replies are listed 'Best First'.
Re^2: Archive::Tar fails to dereference and save symlinks?
by Anonymous Monk on Sep 16, 2011 at 03:34 UTC
    Thanks, but there's something different about our environments.

    I downloaded your code. Commented out the "Data::Dumper::Concise" since you don't use it and it isn't installed on my system. Changed output file name (don't have a Desktop on this system).

    Still get error. Yes, the .tgz gets created (didn't notice this before).

    More interesting, if instead of a 0 byte file (Did you duplicate that?), I do echo "abcd">foo - the error goes away.

    BUT: the .tgz is corrupt. Sometimes.

    #!/usr/bin/perl -slw use strict; use Archive::Tar; #use Data::Dumper::Concise; $Archive::Tar::FOLLOW_SYMLINK = 1; print $Archive::Tar::VERSION; my $t = Archive::Tar->new; $t->add_files('bar'); $t->write( 'baz.tgz', COMPRESS_GZIP ); $t->error(1); print "Done"; ls -l foo bar baz.tgz ls: cannot access baz.tgz: No such file or directory lrwxrwxrwx. 1 root root 3 Sep 15 19:35 bar -> foo -rw-r--r--. 1 root root 0 Sep 15 23:19 foo # perl z.tmp 1.78 Could not write data for: bar at z.tmp line 12 Done # echo "abcd" >foo # ls -l foo bar baz.tgz lrwxrwxrwx. 1 root root 3 Sep 15 19:35 bar -> foo -rw-r--r--. 1 root root 97 Sep 15 23:21 baz.tgz -rw-r--r--. 1 root root 5 Sep 15 23:20 foo # rm baz.tgz # perl z.tmp 1.78 Done ]# ls -l foo bar baz.tgz lrwxrwxrwx. 1 root root 3 Sep 15 19:35 bar -> foo -rw-r--r--. 1 root root 97 Sep 15 23:25 baz.tgz -rw-r--r--. 1 root root 5 Sep 15 23:20 foo And sometimes, I get # tar -tzvf baz.tgz -rw-r--r-- root/root 0 2011-09-15 19:35 bar tar: Skipping to next header tar: Exiting with failure status due to previous errors
    I'm not hallucinating. (This is a reduced test case from larger program; it normally does more work.)