FredKJ has asked for the wisdom of the Perl Monks concerning the following question:

I have a project where I will have to manage tar files. Due to system requirements I won't be able to use Archive::Tar. Are there any good references, books etc. that deal with this?

Replies are listed 'Best First'.
Re: scripting tar
by zentara (Cardinal) on Jan 30, 2009 at 19:21 UTC
    You can run it thru system or backticks, but the syntax for options can get tricky. For instance
    system ('tar','-c','-XEXCLUDE_FILE','-M','-L50000',"-F ./backup-rotate +.pl $basename","-f$basename-0.tar",$dir);

    I'm not really a human, but I play one on earth Remember How Lucky You Are
      Is there a specific reason why you would have to use perl for this? This could easily be written in a shell (bash,csh, etc) script.
        Is there a specific reason why you would have to use perl for this

        Well, that line was pulled from a more complex script, that is far easier to do in Perl, than something like bash shell. For instance, what if you were automating writing the tarballs to a cd/dvd, or transferring it over a socket to another location, forking the work off, etc. Additionally, file and directory operations are soooo much easier with Perl, than shell, especially if you are used to Perl and abhor shell syntax.

        So....it is often better to use Perl , and run the occaisional command thru system/backtick/pipe, and have the full power of Perl available when needed for things shell dosn't do well.


        I'm not really a human, but I play one on earth Remember How Lucky You Are
Re: scripting tar
by MidLifeXis (Monsignor) on Jan 30, 2009 at 19:20 UTC

    man tar

    --MidLifeXis

Re: scripting tar
by CountZero (Bishop) on Jan 31, 2009 at 07:59 UTC
    Due to system requirements I won't be able to use Archive::Tar.
    I am always interested to know what these "system requirements" could be.

    Archive::Tar is now a core module (first released with perl 5.009003), so it should be available on all modern Perl-installations for all types of OS and can easily be installed on older versions through CPAN as it is a "Perl-only" module, no compiler needed.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James