Right: I got this script that I use to check a directory's size and if it's larger than 5mb, compress it, unlink the files once compressed, and write the zip to another directory, reading the names of the previous zips and incrementing the number at the end. However, I have a problem, and I think it's to do with getting parameters as an array. When I shift() to get the files that need to be compressed, I only get the first one. I tried foreaching over them and pushing them onto the array, but still get the same output, only one file getting compressed each time. Is there a procedure for getting lists? I didn't think so, so my problem's probably elsewhere. Here's my code:
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'); }
(populate() is a sub that just slurps every file in a dir into an array, not counting '.' and '..').

In reply to Recieving lists as arguments by Amoe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.