Amoe has asked for the wisdom of the Perl Monks concerning the following question:
(populate() is a sub that just slurps every file in a dir into an array, not counting '.' and '..').use strict; use warnings; use diagnostics; use populate; use Archive::Zip; my($store_path); my(@pictures, $picture); my($cumulative, $size); $store_path = './store'; @pictures = populate($store_path); foreach $picture (@pictures) { $size = (stat($picture))[7]; $cumulative += $size; } &make_barn(@pictures) if ($cumulative >= 5000000); sub make_barn { my($barns_path); my(@pictures, $picture); my($barn_number, @barns); my($barn, $member); @pictures = shift(); # broken $barns_path = './barns'; $barn = Archive::Zip->new(); foreach $picture (shift()) { $member = $barn->addFile($picture); $member->desiredCompressionLevel(9); print "Added $picture\n"; } @barns = populate($barns_path); ($barn_number) = $barns[0] =~ /barn_(.+)\.zip$/; $barn_number++; $barn->writeToFileNamed($barns_path.'/barn_'.$barn_number.'.zip'); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Recieving lists as arguments
by lhoward (Vicar) on Jul 12, 2001 at 20:46 UTC | |
|
Re: Recieving lists as arguments
by Masem (Monsignor) on Jul 12, 2001 at 20:45 UTC | |
|
Re: Recieving lists as arguments
by the_slycer (Chaplain) on Jul 12, 2001 at 21:05 UTC | |
|
Re: Recieving lists as arguments
by dsb (Chaplain) on Jul 12, 2001 at 20:59 UTC | |
|
Re: Recieving lists as arguments
by bikeNomad (Priest) on Jul 12, 2001 at 20:50 UTC | |
|
Re: Recieving lists as arguments
by MZSanford (Curate) on Jul 12, 2001 at 22:09 UTC | |
by japhy (Canon) on Jul 12, 2001 at 22:15 UTC |