~ubuntu-branches/ubuntu/trusty/horae/trusty

« back to all changes in this revision

Viewing changes to 0CPAN/Archive-Zip-1.16/examples/zip.pl

  • Committer: Bazaar Package Importer
  • Author(s): Carlo Segre
  • Date: 2008-02-23 23:13:02 UTC
  • mfrom: (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080223231302-mnyyxs3icvrus4ke
Tags: 066-3
Apply patch to athena_parts/misc.pl for compatibility with 
perl-tk 804.28.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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;