While these file tests are fine for testing various attributes regarding a particular file or filehandle, they don't tell the whole story. For example, there's no file test that returns the number of links to a file. To
get at the remaining information about a file, merely call the
function, which returns pretty much everything that the
POSIX system call returns (hopefully more than you want to know).
The operand to
is a filehandle or an expression that evaluates to a filename. The return value is either
, indicating that the stat failed, or a 13-element list,[
] most easily described using the following list of scalar variables:
$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat(...)
The names here refer to the parts of the stat structure, described in detail in your
(2) manpage. You should probably look there for the detailed descriptions.
For example, to get the
user ID and the
group ID of the password file, let's try:
($uid, $gid) = (stat("/etc/passwd"))[4,5];
And that's the way it goes.
function on the name of a symbolic link returns information on what a symbolic link points at, not information about the symbolic link itself (unless the link just happens to be pointing at nothing currently accessible). If you need the (mostly useless) information about the symbolic link itself, use
(which returns the same information in the same order). The
function works like
on things that aren't symbolic links.
Like the file tests, the operand of
, meaning that the stat will be performed on the file named by the scalar variable