1Archive::Tar(3) User Contributed Perl Documentation Archive::Tar(3)
2
3
4
6 Archive::Tar - module for manipulations of tar archives
7
9 use Archive::Tar;
10 my $tar = Archive::Tar->new;
11
12 $tar->read('origin.tgz');
13 $tar->extract();
14
15 $tar->add_files('file/foo.pl', 'docs/README');
16 $tar->add_data('file/baz.txt', 'This is the contents now');
17
18 $tar->rename('oldname', 'new/file/name');
19 $tar->chown('/', 'root');
20 $tar->chown('/', 'root:root');
21 $tar->chmod('/tmp', '1777');
22
23 $tar->write('files.tar'); # plain tar
24 $tar->write('files.tgz', COMPRESS_GZIP); # gzip compressed
25 $tar->write('files.tbz', COMPRESS_BZIP); # bzip2 compressed
26 $tar->write('files.txz', COMPRESS_XZ); # xz compressed
27
29 Archive::Tar provides an object oriented mechanism for handling tar
30 files. It provides class methods for quick and easy files handling
31 while also allowing for the creation of tar file objects for custom
32 manipulation. If you have the IO::Zlib module installed, Archive::Tar
33 will also support compressed or gzipped tar files.
34
35 An object of class Archive::Tar represents a .tar(.gz) archive full of
36 files and things.
37
39 Archive::Tar->new( [$file, $compressed] )
40 Returns a new Tar object. If given any arguments, new() calls the
41 read() method automatically, passing on the arguments provided to the
42 read() method.
43
44 If new() is invoked with arguments and the read() method fails for any
45 reason, new() returns undef.
46
47 $tar->read ( $filename|$handle, [$compressed, {opt => 'val'}] )
48 Read the given tar file into memory. The first argument can either be
49 the name of a file or a reference to an already open filehandle (or an
50 IO::Zlib object if it's compressed)
51
52 The "read" will replace any previous content in $tar!
53
54 The second argument may be considered optional, but remains for
55 backwards compatibility. Archive::Tar now looks at the file magic to
56 determine what class should be used to open the file and will
57 transparently Do The Right Thing.
58
59 Archive::Tar will warn if you try to pass a bzip2 / xz compressed file
60 and the IO::Uncompress::Bunzip2 / IO::Uncompress::UnXz are not
61 available and simply return.
62
63 Note that you can currently not pass a "gzip" compressed filehandle,
64 which is not opened with "IO::Zlib", a "bzip2" compressed filehandle,
65 which is not opened with "IO::Uncompress::Bunzip2", a "xz" compressed
66 filehandle, which is not opened with "IO::Uncompress::UnXz", nor a
67 string containing the full archive information (either compressed or
68 uncompressed). These are worth while features, but not currently
69 implemented. See the "TODO" section.
70
71 The third argument can be a hash reference with options. Note that all
72 options are case-sensitive.
73
74 limit
7