@filenames is just the list of files in the directory, unless you are
running the script from the directory you are reading (in which case your
ArchivePath would also work with ".", you need to prepend the dir path to the
file name, ie:
next
if (-M "$archivePath/$tstfile" < 30);
-Peter
-----Original Message-----
From: Pamela Benus [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 08, 2002 5:45 AM
To: [EMAIL PROTECTED]
Subject: -M file test works on Windows 2000, fat32 files but not on NT server, NTFS files
I developed the code below to test how many days since a file had been last modified. It was developed on a Windows 2000 PC with fat32 file structure.
The tests were successful. I moved the code to a NT server with NTFS file structure. We also tried stat. We can get all of the file tests to work on the PC but we do not get any results from the server where the code actually needs to be. This is the first perl program I have written so be gentle :) My boss does not understand why it doesn't work. The unlink works on the PC but is currently commented out while working through this problem.
Perl Code:
#!E:\perl\bin\perl.exe
use CGI qw(:all);
$query=new CGI;
use Time::localtime;
# This program deletes archived batch file maintenance files that are
# 30 days old or older.
$archivePath = "e:/lotus/domino/data/ftp/hrs/archive";
#opening the directory
opendir(DIR, $archivePath) or die "can't opendir $archivePath: $!";
@filenames = readdir DIR;
foreach my $tstfile (@filenames) {
next if (-M $tstfile < 30); #only want over 29 days old files
$_ = $tstfile;
if (/PRA.TXT.UIS/) {
$howlong = -M $tstfile; #debugging
print "$tstfile is $howlong old\n"; #debugging
push(@rray,$tstfile);
}
}
print "\@rray contains @rray\n"; #debugging
# unlink @rray; # this statement days deletes the array of files
closedir (Dir);
--------------------------------------------------------------------------------------------------------------------------------
thank you for any insight,
Pamela Benus
