Debian lenny version packages
[pkg-perl] / deb-src / libarchive-zip-perl / libarchive-zip-perl-1.18 / examples / zip.pl
1 #!/bin/perl -w
2 # Creates a zip file, adding the given directories and files.
3 # Usage:
4 #       perl zip.pl zipfile.zip file [...]
5
6 use strict;
7 use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
8
9 die "usage: $0 zipfile.zip file [...]\n"
10         if (scalar(@ARGV) < 2);
11
12 my $zipName = shift(@ARGV);
13 my $zip = Archive::Zip->new();
14
15 foreach my $memberName (map { glob } @ARGV)
16 {
17         if (-d $memberName )
18         {
19                 warn "Can't add tree $memberName\n"
20                         if $zip->addTree( $memberName, $memberName ) != AZ_OK;
21         }
22         else
23         {
24                 $zip->addFile( $memberName )
25                         or warn "Can't add file $memberName\n";
26         }
27 }
28
29 my $status = $zip->writeToFileNamed($zipName);
30 exit $status;