如何找到创建或更新当前日期的文件/

问题描述:

如何找到创建或更新当前日期的文件/天如何找到创建或更新当前日期的文件/

您可以使用-M函数来查看文件是否在过去被修改天:

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

您还可以测试的时间,因为这个inode与-C,这是经常改变(但不总是)创建文件时(见here对文件系统的兼容性问题)。

有关各种文件测试的一些示例,请参阅here

在File :: Stat上显示。您可以使用DateTime来初始化本地时区的时间戳。

假设你想一天,该文件的日期,当它最后被修改,你可以尝试这样的

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";