9 getopts('dcvzthxf:I', $opts) or die usage();
11 ### show the help message ###
12 die usage() if $opts->{h};
14 ### enable debugging (undocumented feature)
15 local $Archive::Tar::DEBUG = 1 if $opts->{d};
17 ### enable insecure extracting.
18 local $Archive::Tar::INSECURE_EXTRACT_MODE = 1 if $opts->{I};
21 unless ( 1 == grep { defined $opts->{$_} } qw[x t c] ) {
22 die "You need exactly one of 'x', 't' or 'c' options: " . usage();
25 my $compress = $opts->{z} ? 1 : 0;
26 my $verbose = $opts->{v} ? 1 : 0;
27 my $file = $opts->{f} ? $opts->{f} : 'default.tar';
28 my $tar = Archive::Tar->new();
33 find( sub { push @files, $File::Find::name;
34 print $File::Find::name.$/ if $verbose }, @ARGV );
36 Archive::Tar->create_archive( $file, $compress, @files );
40 my $tar = Archive::Tar->new($file, $compress);
43 print map { $_->full_path . $/ } $tar->get_files;
45 } elsif( $opts->{x} ) {
46 print map { $_->full_path . $/ } $tar->get_files
48 Archive::Tar->extract_archive($file, $compress);
55 Usage: ptar -c [-v] [-z] [-f ARCHIVE_FILE] FILE FILE ...
56 ptar -x [-v] [-z] [-f ARCHIVE_FILE]
57 ptar -t [-z] [-f ARCHIVE_FILE]
60 ptar is a small, tar look-alike program that uses the perl module
61 Archive::Tar to extract, create and list tar archives.
64 x Extract from ARCHIVE_FILE
65 c Create ARCHIVE_FILE from FILE
66 t List the contents of ARCHIVE_FILE
67 f Name of the ARCHIVE_FILE to use. Default is './default.tar'
68 z Read/Write zlib compressed ARCHIVE_FILE (not always available)
69 v Print filenames as they are added or extraced from ARCHIVE_FILE
70 h Prints this help message
71 I Enable 'Insecure Extract Mode', which allows archives to extract
72 files outside the current working directory. (Not advised).
83 ptar - a tar-like program written in perl
87 ptar is a small, tar look-alike program that uses the perl module
88 Archive::Tar to extract, create and list tar archives.
92 ptar -c [-v] [-z] [-f ARCHIVE_FILE] FILE FILE ...
93 ptar -x [-v] [-z] [-f ARCHIVE_FILE]
94 ptar -t [-z] [-f ARCHIVE_FILE]
99 x Extract from ARCHIVE_FILE
100 c Create ARCHIVE_FILE from FILE
101 t List the contents of ARCHIVE_FILE
102 f Name of the ARCHIVE_FILE to use. Default is './default.tar'
103 z Read/Write zlib compressed ARCHIVE_FILE (not always available)
104 v Print filenames as they are added or extraced from ARCHIVE_FILE
105 h Prints this help message
109 tar(1), L<Archive::Tar>.