http://www.perlmonks.org?node_id=71715
Category: Utility Scripts
Author/Contact Info Simon Flack - $code or die
perl@simonflack.com
Description: I wanted to find a simple command line TAR\GZ program for Windows to GZip my modules for uploading to CPAN. But I couldn't find one I liked.

Of course there is always cygwin which I urge everyone to download who use "explorer.exe" as a shell. It's only a small download.

However, this fitted my needs. Please let me know any comments or improvements.

Update: You might also want to check out btrott's script which does the same thing but also stores the path. I didn't see this before I posted mine.
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;
}