File::stat
use File::stat;
$st = stat($file) or die "Can't stat $file: $!";
if ($st->mode & 0111 and $st->nlink > 1)) {
print "$file is executable with many links\n";
}
use File::stat ":FIELDS";
stat($file) or die "Can't stat $file: $!";
if ($st_mode & 0111 and $st_nlink > 1) ) {
print "$file is executable with many links\n";
}
@statinfo = CORE::stat($file); # Access overridden built-in.The File::stat module provides a method
interface to Perl's built-in stat and
lstat functions by replacing them with versions
that return a File::stat object (or
undef on failure). This object has methods that
return the like-named structure field name from the traditional
stat (2) syscall; namely,
dev, ino,
mode, nlink,
uid, gid,
rdev, size,
atime, mtime,
ctime, blksize, and
blocks. You may also import the structure fields
into your own namespace as regular variables using the
":FIELDS" import tag. (This still overrides your
stat and lstat built-ins.) These
fields show up as scalar variables named with a
"st_" in front of the field name. That is, the
$st_dev variable corresponds to the
$st->dev method.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access