Hi all,
 
I am attempting to list out the contents of a directory, and print the
last time accessed.  The data-time is not correct though.  I am running
this code on a Windows XP workstation.  There doesn't seem to be a real
easy way to get the timestamps of directories.  Hmmmm....   Here is the
code:
 
# deldir4.pl
use strict;
# use warnings;
use File::Find;
 
my $DIRHANDLE;
my $file;
my $write_secs;
 
opendir $DIRHANDLE, "$ARGV[0]" or die "Can't open directory handle: $!";
 
 while ($file = readdir $DIRHANDLE) {
  $write_secs = (stat($file))[9];
      printf "file %s updated at %s\n", $file,
         scalar localtime($write_secs);
  } 
 
closedir $DIRHANDLE;
 
I get the following output:
 
C:\BegPerl>deldir4.pl c:\db2_backup\udbt.0\db2\node0000\catn0000
file . updated at Wed Dec  1 10:53:32 2004
file .. updated at Tue Jan  1 00:00:00 1980
file 20050204 updated at Wed Dec 31 17:00:00 1969
file 20050228 updated at Wed Dec 31 17:00:00 1969
file 20050301 updated at Wed Dec 31 17:00:00 1969
file 20050302 updated at Wed Dec 31 17:00:00 1969
file 20050304 updated at Wed Dec 31 17:00:00 1969
file dir.lst updated at Wed Dec 31 17:00:00 1969
file march.txt updated at Wed Dec 31 17:00:00 1969
 
C:\BegPerl>
 

Reply via email to