2010-10-28 70 views

回答

3

您可以使用-M函數來查看文件是否在過去被修改天:

if(-M FH < 1) { 
    # file was modified less than one day ago 
} 

您還可以測試的時間,因爲這個inode與-C,這是經常改變(但不總是)創建文件時(見here對文件系統的兼容性問題)。

有關各種文件測試的一些示例,請參閱here

1

在File :: Stat上顯示。您可以使用DateTime來初始化本地時區的時間戳。

2

假設你想一天,該文件的日期,當它最後被修改,你可以嘗試這樣的

use strict; 
use warning; 
use File::stat; 
use Time::localtime; 

my $st = stat($file) or die "No $file: $!"; 
my $datetime_string = ctime($st->mtime); 

print "file $file was updated at $datetime_string\n"; 
相關問題