目录

stat

描述 (Description)

此函数返回一个13元素数组,给出文件的状态信息,由FILEHANDLE,EXPR或$ _指定。 返回的值列表如下表所示。 如果在标量上下文中使用,则在失败时返回0,在成功时返回1。

请注意,对这些元素中的某些元素的支持取决于系统。 查看文档以获取完整列表。

Element Description
0 	Device number of file system
1 	Inode number
2 	File mode (type and permissions)
3 	Number of (hard) links to the file
4 	Numeric user ID of file.s owner
5 	Numeric group ID of file.s owner
6 	The device identifier (special files only)
7 	File size, in bytes
8 	Last access time since the epoch
9 	Last modify time since the epoch
10 	Inode change time (not creation time!) since the epoch
11 	Preferred block size for file system I/O
12	Actual number of blocks allocated

语法 (Syntax)

以下是此函数的简单语法 -

stat FILEHANDLE
stat EXPR
stat

返回值 (Return Value)

此函数返回ARRAY,($ device,$ inode,$ mode,$ nlink,$ uid,$ gid,$ rdev,$ size,$ atime,$ mtime,$ ctime,$ blksize,$ blocks)

例子 (Example)

以下是显示其基本用法的示例代码 -

#!/usr/bin/perl -w
($device, $inode, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
   $ctime, $blksize, $blocks) = stat("/etc/passwd");
print("stat() $device, $inode, $ctime\n");

执行上述代码时,会产生以下结果 -

stat() 2065, 5374250, 1508051555
↑回到顶部↑
WIKI教程 @2018