stat FILEHANDLE stat EXPR stat |
返回一个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
数组, ($device, $inode, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks)
试试下面的例子:
#!/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() 147, 20212116, 1177094582