Here's my script for setting the mdate/cdate for one file to match 
another.  

Specifically, look at perldoc -f stat.

!/usr/bin/perl -w

unless ( $ARGV[1]) {
  print STDERR "utime: usage - utime file1 file2\n";
  print STDERR "utime: modifies the accessed and modified dates of 
file2 to match\n";
  print STDERR "utime: those of file1\n";
  exit 1;
}

die "utime: $ARGV[0] does not exist\n" unless ( -f $ARGV[0]);
die "utime: $ARGV[1] does not exist\n" unless ( -f $ARGV[1]);
die "utime: $ARGV[1] not writable\n" unless ( -w $ARGV[1]);
my ($atime,$mtime)=(stat($ARGV[0]))[8,9];

# print "atime= ",scalar(localtime($atime)),"\n";
# print "amime= ",scalar(localtime($mtime)),"\n";

if ( $ARGV[1]) {
 #print "utime returned '",utime $atime,$mtime,$ARGV[1];
 utime $atime,$mtime,$ARGV[1];
 #print "'\n";
}

hope it helps
On Thursday 03 May 2001 10:29 am, Julian Church wrote:
> I'm a very fresh novice at Perl.  I'm using Apache on my office
> Windows NT server to serve up a small intranet site.  I've written
> one small but practical server side include in perl and am now
> starting on my second.
>
> Can anyone tell me how to use Perl to obtain the modification /
> creation date of a file on an NT 4 machine?

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 
    

Reply via email to