此函数执行与FILEHANDLE或EXPR或$_引用的文件上的stat函数相同的测试。
如果文件是符号链接,则它返回链接的信息,而不是它指向的文件。否则,它将返回文件的信息。
以下是此函数的简单语法-
链接:https://www.learnfk.comhttps://www.learnfk.com/perl/perl-lstat.html
来源:LearnFk无涯教程网
lstat FILEHANDLE lstat EXPR lstat
此函数在列表context中返回包含13个元素的列表,这些字段如下-
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 total size of file, in bytes 8 atime last access time in seconds since the epoch 9 mtime last modify time in seconds since the epoch 10 ctime inode change time in seconds since the epoch (*) 11 blksize preferred block size for file system I/O 12 blocks actual number of blocks allocated
注意-时代是格林尼治标准时间1970年1月1日00:00。
以下是显示其基本用法的示例代码-
#!/usr/bin/perl -w $filename = "/tmp/test.pl"; ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize, $blocks) = lstat($filename); printf "File is %s,\n size is %s,\n perm %04o, mtime %s\n", $filename, $size, $mode & 07777, scalar localtime $mtime;
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)