大佬教程收集整理的这篇文章主要介绍了如何获取文件的最后修改时间在Perl?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
调用stat($ fh)返回一个数组,其中包含有关传入(从perlfunc man page for stat
)的文件句柄的以下信息:
0 dev device number of filesystem 1 ino inode number 2 mode file mode (type and permissions) 3 nlink number of (hard) links to the file 4 uid numeric user ID of file's owner 5 gid numeric group ID of file's owner 6 rdev the device identifier (special files only) 7 size @R_504_10586@l size of file,in bytes 8 atime last access time since the epoch 9 mtime last modify time since the epoch 10 ctime inode change time (NOT creation time!) since the epoch 11 blksize preferred block size for file system I/O 12 blocks actual number of blocks allocated
此数组中的第9个元素将为您提供自时代(1970年1月1日格林尼治时间1970年1月1日)以来的最后修改时间。从中你可以确定当地时间:
@H_179_8@my $epoch_timestamp = (stat($fh))[9]; my $timestamp = localtime($epoch_timestamp);为了避免在前面的例子中需要的幻数9,另外使用Time :: localtime,另一个内置模块(也包括在Perl 5.004中)。这需要一些(可以说)更清晰的代码:
use File::stat; use Time::localtime; my $timestamp = ctime(stat($fh)->mtimE);
以上是大佬教程为你收集整理的如何获取文件的最后修改时间在Perl?全部内容,希望文章能够帮你解决如何获取文件的最后修改时间在Perl?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。