Created
January 27, 2010 20:54
-
-
Save xaicron/288147 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Encode; | |
use Archive::Zip; | |
use Pod::Usage qw/pod2usage/; | |
use opts; | |
opts | |
my $from => { isa => 'Str', default => 'utf8' }, | |
my $to => { isa => 'Str', default => 'utf8' }, | |
my $help => { isa => 'Bool' }, | |
; | |
pod2usage 1 if $help; | |
my $file = shift || pod2usage 1; | |
&main();exit; | |
sub main { | |
my $zip = Archive::Zip->new; | |
die "$file read failed" unless $zip->read($file) == Archive::Zip::AZ_OK; | |
for my $member ($zip->memberNames) { | |
my $extract_name = encode $to => decode $from => $member; | |
print "exsits $extract_name\n" and next if -f $extract_name; | |
$zip->extractMember($member, $extract_name); | |
} | |
} | |
__END__ | |
=head1 NAME | |
unzip.pl - unzip with encoding. | |
=head1 SYNOPSIS | |
unzip.pl [--from encoding --to encoding --hellp] zip_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment