readdir is raw eggs, what you want is cake
#!/usr/bin/perl -- use strict; use warnings; ## Main( @ARGV ); Main( "zipdir", "unzipdir" ); exit( 0 ); sub Main { my( $zipdir, $unzipdir ) = @_; my @zipped = GetZipFiles( $zipdir ); my @unzipped = GetZipFiles( $unzipdir ); if( @zipped == @unzipped ){ MatchBanana( \@zipped, \@unzipped ); } else { die "zipped number not equal to unzipped number, bye!\n"; } } sub MatchBanana { my( $zip, $unzip ) = @_; for my $ix ( 0 .. $#{$zip} ){ my $inf = $zip->[$ix]; my $outf = $unzip->[$ix]; unzip $inf, $outf or die "unzip failed: $UnzipError \n"; } } sub GetZipFiles { use Path::Tiny qw/ path /; my( $zipdir ) = @_; my @zipfiles = path( $zipdir )->children( qr/\.zip$/i ); return @zipfiles; }
Even this program has problems, the zipfiles arent sorted , whos to say the infile really go with the outfiles
In reply to Re^3: unzip fail using IO::Uncompress::Unzip
by Anonymous Monk
in thread unzip fail using IO::Uncompress::Unzip
by keienn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |