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

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.