I think I got a case where I can reproduce this strange behaviour. At least I could provoke it several times repeatedly. Here is an example from the Windows command line (I'm using the DEL command to erase the file instead Perl's unlink; "ls" is the GnuUtil's ls.exe):
C:\>ls -l pid.txt
-rw-rw-rw- 1 user group 4 Sep 15 16:51 pid.txt
C:\>type pid.txt
8748
C:\>perl -lwe "print(':'.localtime((stat 'pid.txt')[10]))"
:Thu Sep 15 16:45:56 2011
C:\>del pid.txt
C:\>echo 8748 >pid.txt
C:\>perl -lwe "print(':'.localtime((stat 'pid.txt')[10]))"
:Thu Sep 15 16:45:56 2011
We can see that the ctime did not change, although I erased pid.txt and created a new version! Now for a new experiment:
C:\>move pid.txt pid.old
1 file(s) moved.
C:\>echo 8749 >pid.txt
C:\>perl -lwe "print(':'.localtime((stat 'pid.txt')[10]))"
:Thu Sep 15 16:45:56 2011
First, I moved the old pid.txt away; then a created a new one. I still get the old time stamp!!! But now look at this:
C:\>del pid.txt
C:\>perl -lwe "print(':'.localtime((stat 'pid.txt')[10]))"
Use of uninitialized value in localtime at -e line 1.
:Thu Jan 1 01:00:00 1970
C:\>echo 8750 >pid.txt
C:\>perl -lwe "print(':'.localtime((stat 'pid.txt')[10]))"
:Tue Sep 20 11:30:49 2011
I delete the file, as in the very first example before. Then I run my perl command to display the ctime of the non-existing file. Not surprisingly, I get an error message. Now I re-create pid.txt and get the ctime. THIS TIME the ctime is up-to-date!!!!
The last (third) example differs from the first one only in that I asked Windows for the ctime of the *deleted* pid.txt. This seemed to "erase" the old timestamp somehow!
This doesn't look to me like a Perl problem anymore. It seems to be a pure Windows problem. My apologies for having it posted here...
--
Ronald Fischer <ynnor@mm.st>
|