The compiled "tar" command itself (gnu version -- the de facto standard) is available for every major OS type/version.
Windows does not come with any tar command, neither GNU nor any other implementation. Using the core Archive::Tar seems reasonable there. Especially if there is some braindead corporate policy that disallows installing third party software, except of course those that has been blessed by an incompetent committee.
I don't have much experience with Solaris, but I would not bet a cent that Solaris' default tar is GNU tar. I would rather expect it to be some legacy implementation with a very different behaviour. Sure, Solaris has GNU tools, either out of the box or via sunfreeware.org. But they aren't the default, and they are installed in places where the average Linux user would never look for them. Again, using Archive::Tar makes live easier. You don't have to remember that tar is /usr/ucb4/sunfreeware/gnu/current/bin/tar (or something like that) if $^O=~/sun|solaris/i, and /bin/tar, /usr/bin/tar or just the first tar found in $ENV{PATH} (except, of course, if $^O=~/win/i).
Besides, I think OS/2 did not come with a tar implementation, and I'm sure many other non-Unix operating systems don't have tar, either. And if they do, their tar may behave very different from what you expect after working (too) long with GNU tar.
So, there are reasons to use Archive::Tar, even if it is slow and eats lots of memory.
And to solve the riddle why Archive::Tar does not add the contents of a directory when it's add_files() method is called with a directory name: RTFM! add_files() needs a list of files (including the directories), not a directory name. Use glob or File::Find to build that list.
Also note that Archive::Tar comes with a ptar (Perl TAR) utility, from where you can extract the relevant code.
Alexander
In reply to Re^2: Archiving a directory and its contents with Archive::Tar
by afoken
in thread Archiving a directory and its contents with Archive::Tar
by vendion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |