[thelist] Perl Problem.

Peter Bancroft pdb103 at york.ac.uk
Sun Aug 27 18:31:07 CDT 2000


A problem a friend has with a perl problem.. unfortunately, my Perl really
isn't very good.  Any of you know the problem?  Algian says thanks in
advance :)
-Peter

#get the time now and set time limit
my $now = time;
my $secs = 18000;

#get the file and delete as appropriate
opendir(TEMP, "c:/my/directory/here/");
 for (readdir(TEMP)) {
  if ($_ =~ /.save/g || $_ eq "." || $_ eq "..") {;}
  else {
   my $atime = (stat "c:/my/directory/here/$_")[8];
   print "$_ $atime ";
   if (($now - $atime) > $secs) {
    unlink("c:/my/directory/here/$_");
   }
  }
 }
closedir(TEMP);

the problem is in the $atime. I made the perl print out the $_ which is the
name of a file
and the atimeof that file (atime being the last time the file was accessed.
the problem is that for the 2 files in that directory is that they both give
me the same atime and i know for a fact that one of those 2 files hasn't
been accessed for at least 1.5 months. and i tried using other files i
haven't accessed and it still won't work. Does anyone have any clue why this
is? I've been trying to change the code here and there but it still gives
the same result the atime doesn't change for some reason so the files with
over 5 hours are never deleted.







More information about the thelist mailing list