It looks like you can use Archive::Zip to open up a Zip file.

use Archive::Zip; my $zip = Archive::Zip->new("yourfile.zip");

Once you have the Zip file opened, use the members() method to get a list of files contained in the Zip archive, and loop over them:

my @members = $zip->members(); foreach my $member (@members) { # ... }

Where the # ... is is where the interesting bits of your code need to go. In order to check out the last modified time of the $fh you have, call $member->lastModTime().

So let's put this together...

#!/usr/bin/perl -T use strict; use warnings; use Archive::Zip; my $zip = Archive::Zip->new("file.zip"); my $members = $zip->members(); my $firstdate; my $lastdate; # No need to fill these in with "never", because I hav +e had dates before. ;-) foreach my $member (@members) { my $filedate = $member->lastModTime(); if (($filedate < $firstdate) || (!defined($firstdate)) { $firstdate = $filedate; } if ((!defined($lastdate) || ($filedate > $lastdate)) { $lastdate = $filedate; } } $fh->close(); # Calculate the difference between the first and last # file dates... my $datediff = $lastdate - $firstdate; # Check if the time difference between the first and last # files is more than 3 months... if ($datediff > (60 * 60 * 24 * 30 * 3)) { # You need a new file }

Please note that this code is completely untested, but it should at least be a reasonable start...


In reply to Re: Checking file dates in a Zip file by Yendor
in thread Checking file dates in a Zip file by sparkel

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.