The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tar - module for manipulation of tar archives.

SYNOPSIS

  use Tar;

  $tar = Tar->new();
  $tar->add_files("file/foo.c", "file/bar.c");
  $tar->add_data("file/bar.c","This is the file contents");
  $tar->write("files.tar");

DESCRIPTION

This module is definitely tentative, and several things will be changed rather shortly. The exported routines will not be exported [done], all the calls to croak() should be replaced with returning undef() and putting error messages in a package global [done].

At the moment these methods are implemented:

new()

Returns a new Tar object. If given a filename as an argument, it will try to load that as a tar file.

add_files(@filenamelist)

Takes a list of filenames and adds them to the in-memory archive.

add_data($filename,$data,$opthashref)

Takes a filename, a scalar full of data and optionally a reference to a hash with specific options. Will add a file to the in-memory archive, with name $filename and content $data. Specific options can be set using $opthashref, which will be documented later.

remove(@filenamelist)

Removes any entries with names matching any of the given filenames from the in-memory archive. String comparisons are done with eq.

read('file.tar')

Try to read the given tarfile into memory. Will replace any previous content in $tar!

write('file.tar')

Will write the in-memory archive to disk.

data()

Returns the in-memory archive. This is a list of references to hashes, the internals of which is not currently documented.

extract(@filenames)

Write files whose names are equivalent to any of the names in @filenames to disk, creating subdirectories as neccesary. This might not work too well under VMS and MacOS.

CHANGES

Version 0.04
Made changes to write_tar so that Solaris' tar likes the resulting archives better.
Protected the calls to readlink() and symlink(). AFAIK this module should now run just fine on Windows NT.
Add method to write a single entry to disk (extract)
Added method to add entries entirely from scratch (add_data)
Changed name of add() to add_file()
All calls to croak() removed and replaced with returning undef and setting Tar::error.
Better handling of tarfiles with garbage at the end.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 93:

=over without closing =back