Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Tar question

by hotshot (Prior)
on Apr 06, 2003 at 12:10 UTC ( [id://248421]=perlquestion: print w/replies, xml ) Need Help??

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

hello monks!

Anyone can recomend on a good module for packing/unpacking files using tar? I need of course support for all tar command line options.

thanks

Hotshot

Replies are listed 'Best First'.
Re: Tar question
by rob_au (Abbot) on Apr 06, 2003 at 12:17 UTC
    The module you seek is Archive::Tar or specifically, Archive::Tar::Win32 if running on a Windows platform, which is transparently used in place of Archive::Tar on Windows platforms. The documentation for this module is very good and there is a sample implementation of tar written in perl using this module included in the module package.

     

    perl -le 'print+unpack("N",pack("B32","00000000000000000000001001000101"))'

      You shouldn't use Archive::Tar::Win32 directly. Just use Archive::Tar, and it will use the Win32 version behind, to fix some resources that doesn't work in the OS Win32.

      From the POD:
      Although rich in features, it is known to not work on Win32 platforms. On those platforms, Archive::Tar will silently and transparently fall back to Archive::Tar::Win32.

      Graciliano M. P.
      "The creativity is the expression of the liberty".

Re: Tar question
by TStanley (Canon) on Apr 06, 2003 at 12:16 UTC
    Uhh...Archive::Tar?

    TStanley
    --------
    It is God's job to forgive Osama Bin Laden. It is our job to arrange the meeting -- General Norman Schwartzkopf
Re: Tar question
by vek (Prior) on Apr 06, 2003 at 17:28 UTC
    A quick search of the CPAN reveals these gems. Remember, the CPAN is your friend.

    -- vek --
Re: Tar question
by graff (Chancellor) on Apr 07, 2003 at 02:22 UTC
    I need of course support for all tar command line options.

    Well, if you really mean all the options, you won't actually find this part in the Archive::Tar module -- the whole option set is only available in the command-line version of tar). Of course, the range of options varies slightly depending on which version of command-line tar you're talking about (GNU tar's option set is a good and at least as broad as the versions that come "standard" on non-linux versions of unix, but is also somewhat different from all of them).

    You'll see from the Arcihve::Tar man page that it provides methods that will cover the create, append, replace, list (tabulate), and extract functions, as well as (un)compression. The listing of files is flexible (you get to choose what file properties to list) and extraction can be to a scalar variable or to a file.

    Everything else about command-line tar -- files to include or exclude from an operation (specified by path, date or whatever), recursion through a directory tree to create a tar set, comparing file dates to decide whether the tarred file is newer or older than a corresponding disk file, and so on -- is stuff you will need to do on your own, probably using other modules, like File::Find.

    If you want all the command-line option functionality, why not just use the basic command-line tool -- it has been ported to windows, and is natively available for unix/linux and now even macs (via OSX). Use perl scripting as a wrapper for it, in case that makes tool easier for you to use.

    Archive::Tar is a totally cool module that enables a lot of stuff that would be awkward or impossible using just the tar command, but replicating all the options functionality of tar (given that tar already provides that) seems unnecessary.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://248421]
Approved by TStanley
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found