in reply to Question on Archive::Tar vs Archive::TarGzip
Getting it right is a matter of understanding File::Find (which has a reputation of being inscrutable). In this case, the first parameter needs to be a hash ref, with at least two keys: { wanted => sub{...}, no_chdir => 1 }.
That's the only thing that needs to change in the snippet. Here it is, fixed to preserve directory structure in the tar file, and this time with bash-style quotes (which I know for sure are correct and do work in a bash shell):
(still updating... :P this time, decided to ditch the "join(...)" for the output file name -- quoting is just so much easier with bash.)perl -MFile::Find -MArchive::Tar -e '$t=Archive::Tar->new(); find( { wanted=>sub{-f && $t->add_files($_)}, no_chdir=>1 }, $ARGV[0] + ); $t->write( "$ARGV[0].tar" )' some_path
|
|---|