File::stat
Provides the same file status information as the Perl
functions stat and lstat. Exports two functions that return
File::stat objects. The objects have methods that return the
equivalent fields from the Unix stat(2)
call:
Field | Meaning |
|---|---|
| Device number of filesystem |
| Inode number |
| File mode |
| Number of links to the file |
| Numeric user ID of owner |
| Numeric group ID of owner |
| Device identifier |
| Size of file, in bytes |
| Last access time |
| Last modified time |
| Inode change time |
| Preferred blocksize for filesystem I/O |
| Number of blocks allocated |
You can access the status fields either with the methods or by
importing the fields into your namespace with the :FIELDS import tag
and then accessing them by prepending st_ to the field name (e.g., $st_mode). Here are examples of doing it
both ways:
use File::stat; $stats = stat($file); print $stats->uid; print $st_uid;
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