看一下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模块。