Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

File::stat

Native Rust implementation built into the interpreter. Runtime: PP. See original documentation for the full Perl reference.

Provides by-name interface to Perl’s stat() builtin. Returns blessed objects with accessor methods for stat fields.

Functions

Accessor methods on the blessed File::stat object. Each returns the corresponding field from stat(2), indexed into the underlying array.

use File::stat;
my $st = stat($filename);
my $uid   = $st->uid;
my $mtime = $st->mtime;

lstat

Like stat, but does not follow symlinks (uses symlink_metadata).

use File::stat;
my $st = lstat('/path/to/symlink');
print $st->mode, "\n";

stat

Returns a blessed File::stat object (arrayref) for a path or filehandle. Follows symlinks.

use File::stat;
my $st = stat('/etc/passwd');
print $st->size, "\n";