gmaniac has asked for the wisdom of the Perl Monks concerning the following question:
Thanks in advance!use Archive::Zip; my @errors; Archive::Zip::setErrorHandler(sub { push @errors, $_[0] }); my $zippath = "../backups/$username"; my $dest_path = '../backups'; my $zip = Archive::Zip->new(); $status =$zip->writeToFileNamed("$dest_path/$username.zip"); @files = $zip->addTree( "$zippath" ); @files = $zip->memberNames(); @file = splice @files, 1, 50; foreach $line (@file) { $fileend = (split(/\./,"$line"))[-1]; if (($fileend eq "jpg") || ($fileend eq "txt")) { $zip->addFile("$line"); #$status = $zip->writeToFileNamed("$dest_path/$username.zip"); } } # Save the Zip file unless ( $zip->writeToFileNamed("../backups/$username.zip") == AZ_OK +) { die 'write error'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Archive::ZIP - Zip selection of files
by Corion (Patriarch) on Apr 10, 2015 at 09:09 UTC | |
by Anonymous Monk on Apr 10, 2015 at 09:21 UTC | |
by Corion (Patriarch) on Apr 10, 2015 at 09:22 UTC | |
by gmaniac (Initiate) on Apr 10, 2015 at 09:42 UTC | |
by Corion (Patriarch) on Apr 10, 2015 at 09:46 UTC | |
|