看看File::stat包。這將替換內部Perl stat命令與命名爲接口。但是,您可以使用內置的stat
命令或File::stat
程序包。
use File::stat;
use feature qw(say);
my $file_stat = stat($file_name);
say "The following times are displayed as seconds since January 1, 1970"
say " File Last Access time: " . $file_stat->atime;
say " File Last Modification time: " . $file_stat->mtime;
say " File inode Change Time: " . $file_stat->ctime;
其中一個應該這樣做。我認爲你最好的選擇可能是mtime
。
如果你不想使用File::Stat
使用內置stat
命令:
say "The following times are displayed as seconds since January 1, 1970"
say " File Last Access time: " . (stat $my_file)[8]
say " File Last Modification time: " . (stat $my_file)[9];
say " File inode Change Time: " . (stat $my_file)[10];
將時間轉換成可讀的東西的人,使用Time::Piece模塊。
舊的/新的意味着一個比較,所以你必須記錄以前的狀態/時間戳/校驗和/無論以確定... – pavel