> Dan Muey wrote: > > > Dan Muey wrote: > > > > I'm looking at Archive::Zip to extract a single text file > > > from a zip > > > > file that is ftped from a winders box to a unix box. > > > > > > > > The zip file conatins only one file, a .txt file, that is > > > compressed > > > > pretty well. (about 170 MB regular 18MB zipped up) > > > > > > > > Data.txt is apx 170MB > > > > Data.txt is zipped into 'data.zip' which is 18MB > > > > File 'data.zip' is ftped from winders to unix server > > > > Now heres' where my perl script comes in: > > > > > > > > Perl/Archive::Zip (or other module???) > > > > Extracts data.txt from data.zip and writes it to > 'local_data.txt' > > > > > > > > Any pointers/ideas/experience about how to do that? > > > > > > Hi Dan. > > > > > > The program below is the very basic stuff to do what you want. It > > > does no error checking except to make sure that the zip > file opened > > > OK, and just extracts the first file in the archive with > to a file > > > with a name prefixed with "local_". You probably need > some exception > > > handling, but how much depends on your data. > > > > > > HTH, > > > > > > Rob > > > > > > > > > use strict; > > > use warnings; > > > > > > use Archive::Zip; > > > > > > my $zip = Archive::Zip->new('data.zip') or die "Failed > to open zip > > > file"; > > > > > > my ($member) = $zip->members; > > > > For grins, if I understand this right this would allow me > to extract a > > couple files based ontheir name: > > > > my $zip = Archive::Zip->new('data.zip') or die "Failed to open zip > > file"; > > > > my @members = $zip->members; > > > > for(@members) { > > if($_->fileName =~ 'super.txt') { > > $_->extractToFileNamed("local_super.txt"); > > if($_->fileName =~ 'two.txt') { > $_->extractToFileNamed("local_two.txt"); > > } > > > > Just curiose if my understanding of this obdject is semi correct. > > > > Yes, but you don't usually put single quotes around a regex, > and what you wrote would match file names like > xxxsuperxtxtxxx. What you mean is
Oh yeah that is what I meant, oops > > if ($_->fileName eq 'super.txt') { > $_->extractToFileNamed('local_super.txt'); > > but you can do all sorts of fun stuff like > > my @members = $zip->membersMatching('^(super|two)\.txt$'); > > If you have Archive::Zip installed then > > perldoc Archive::Zip I'll install it and check it out. I just figured I get the same weird FAQ page that it has on cpan that doesn't really describe any functions. Thanks Rob, Dan > > will tell you all about it. > > Cheers, > > Rob > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]