Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use CGI::Carp qw( fatalsToBrowser set_message ); use File::Temp qw/ :POSIX /; use Net::FTP; use Archive::Zip qw(:ERROR_CODES); # Set up FTP connection my $ftp = Net::FTP->new( $myhost ); $ftp->login( $myuser, $mypass ) || die "Could not login to $host: $ +@"; $ftp->cwd( $ftpsourcedir ) || die "Could not cwd $ftpsourcedir: $@" +; $ftp->binary(); # Get a list of files my @dircontents = $ftp->dir, "\n" || die "Could not list $ftpsource_di +r: $@"; @dircontents = sort( @dircontents ); foreach my $filestats (@dir_contents) { $err_msg = ''; my @stats = split(' ', $filestats); my $filename = $stats[5]; my $file_size = $stats[1]; # I can see the zip file name here. print "\n$filename\n\n"; #unzip these files into a direcotory my $zip = Archive::Zip->new(); my $status = $zip->read($filename); my @members = $zip->memberNames(); die "Read of $zip failed\n" if $status != AZ_OK; foreach (@members) { $zip->extractMember("$_", "temp/$_"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unzipping files into a directory issue!
by Eliya (Vicar) on Feb 17, 2011 at 21:01 UTC | |
by Anonymous Monk on Feb 18, 2011 at 13:44 UTC | |
by Eliya (Vicar) on Feb 18, 2011 at 13:55 UTC | |
|
Re: Unzipping files into a directory issue!
by davido (Cardinal) on Feb 17, 2011 at 20:41 UTC | |
by Anonymous Monk on Feb 18, 2011 at 13:46 UTC | |
|
Re: Unzipping files into a directory issue!
by Gulliver (Monk) on Feb 17, 2011 at 23:37 UTC | |
by Anonymous Monk on Feb 18, 2011 at 13:40 UTC |