in reply to Checking file dates in a Zip file

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...

Replies are listed 'Best First'.
Re^2: Checking file dates in a Zip file
by sparkel (Acolyte) on Dec 02, 2004 at 18:13 UTC
    hehe...that is funny :)

    Thank you...that did work.