use Archive::Tar; use Compress::Zlib; use File::Find; Syntax() unless @ARGV; my $tar = Archive::Tar->new(); find( { wanted => sub { $tar->add_files($_); } }, $ARGV[1]) +; $tardata = $tar->write(); if ($ARGV[2]) { open (GZIP, ">" . $ARGV[0] . ".tar.gz"); binmode(GZIP); my $gz = gzopen(\*GZIP, "wb"); print $gz->gzwrite($tardata); $gz->gzclose(); close(GZIP); } else { my $tardata; open (TAR, ">" . $ARGV[0] . ".tar"); print TAR $tardata; close (TAR); } sub Syntax { print <<eof; TAR and optionally GZIP a directory. tar.pl [tar_name] [dir_2_tar] [GZIP] e.g. tar.pl example /tmp/example 1 will produce example.tar.gz eof exit; }
In reply to TAR.pl by $code or die
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |