you can see the following example:
use strict;
use warnings;
use Archive::Zip;
#use Archive::Tar;
print "Starting...\n";
# Archive::Zip Synopsis (relative path to directory)
my $zip1 = Archive::Zip->new();
$zip1->addFile( 'c:/Perl/bin/ans1.txt' )
or die 'unable to add file to archive';
$zip1->writeToFileNamed('test1.zip');
# Archive::Zip Synopsis (with ALL CAPS DIRECTORY NAME)
my $zip2 = Archive::Zip->new();
$zip2->addFile('c:/Perl/bin/ans1.txt' )
or die 'unable to add file to archive';
$zip2->writeToFileNamed('tests.zip');
# Archive::Tar Synopsis (relative path to directory)
#my $tar3 = Archive::Tar->new;$tar3->add_files( 'MyArchiveFiles/file1.
+txt' )or die 'unable to add file to archive';$tar3->write('test3.tar'
+);
print "Finished successfully!";