~ubuntu-branches/ubuntu/gutsy/horae/gutsy

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Carlo Segre
  • Date: 2006-12-28 12:36:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061228123648-9xnjr76wfthd92cq
Tags: 064-1
New upstream release, dropped dependency on libtk-filedialog-perl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/perl -w
2
 
# Extracts the named files into 'extractTest' subdir
3
 
# usage:
4
 
#       perl extract.pl [-j] zipfile.zip filename [...]
5
 
# if -j option given, discards paths.
6
 
#
7
 
# $Revision: 1.5 $
8
 
#
9
 
use strict;
10
 
 
11
 
my $dirName = 'extractTest';
12
 
 
13
 
use vars qw( $opt_j );
14
 
use Archive::Zip qw(:ERROR_CODES);
15
 
use Getopt::Std;
16
 
 
17
 
$opt_j = 0;
18
 
getopts('j');
19
 
 
20
 
if (@ARGV < 2)
21
 
{
22
 
        die <<EOF
23
 
        usage: perl extract.pl [-j] zipfile.zip filename [...]
24
 
        if -j option given, discards paths.
25
 
EOF
26
 
}
27
 
 
28
 
my $zip = Archive::Zip->new();
29
 
my $zipName = shift(@ARGV);
30
 
my $status = $zip->read( $zipName );
31
 
die "Read of $zipName failed\n" if $status != AZ_OK;
32
 
 
33
 
foreach my $memberName (@ARGV)
34
 
{
35
 
        print "Extracting $memberName\n";
36
 
        $status = $opt_j 
37
 
                ? $zip->extractMemberWithoutPaths($memberName)
38
 
                : $zip->extractMember($memberName);
39
 
        die "Extracting $memberName from $zipName failed\n" if $status != AZ_OK;
40
 
}