2013-04-20 40 views
1

的Perl我寫了這個,找出給定文件的文件創建時間文件創建時間:無法確定在Windows/Cygwin的

#!/usr/bin/perl 
use strict; 
use warnings; 

use File::stat; 

open (my $fh, '<', "abc.txt") or die "$!"; 
my $t = (stat($fh))[9]; 
print $t; 

但是,這並不工作,並給出:

Use of uninitialized value $t in print at ./tests.plx line 9. 

任何人都可以指出我在這裏做錯了嗎?或者這不能在Windows/Cygwin上的perl(5.14.2)上完成,我必須選擇一些替代方法?

在此先感謝。

+0

http://stackoverflow.com/questions/509576/how-do-i-get-a-files-last-modified-time-in-perl – 2013-04-20 12:50:54

回答

5

stat from File::stat將返回File::stat對象。刪除use File::stat;以獲取數組或使用my $t = stat($fh); print $t->atime;