The stat Function

While these file tests are fine for testing various attributes regarding a particular file or filehandle, they don’t tell the whole story. To get at the remaining information about a file, merely call the stat function, which returns pretty much everything that the POSIX system call stat returns (hopefully more than you want to know). Not all of the stat fields are meaningful under Perl for Win32, because they include information not supported by the Windows NT filesystems.

The operand to stat is a filehandle or an expression that evaluates to a filename. The return value is either undef, indicating that the stat failed, or a 13-element list,[72] most easily described using the following list of scalar variables:

($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,
 $size,$atime,$mtime,$ctime,$blksize,$blocks) = stat(...)

Table 10.2 lists each field along with a brief description.

Table 10-2. stat Return Valves

Field

Description

dev

Device number (drive number)

ino

Inode number: 0 (zero) in Perl for Win32

mode

File permission mode: read/write/execute

nlink

Number of links to file (usually one for Win32 systems—NTFS filesystems may have a value greater than one)

uid

User ID—zero for Win32

gid

Group ID—zero for Win32

rdev

Device Identifier (drive number)

size

File size in bytes

atime

Last access time (C lang. time_t value)

mtime

Last modification time (C lang. time_t value)

ctime

File creation time (C lang. time_t value)

blksize

Disk block size (cluster ...

Get Learning Perl on Win32 Systems now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.