Getting Information on a File : stat « File « Perl






Getting Information on a File

    

The stat function gets a host of information about a file: 

($dev, $inode, $mode, $nlink, $uid, $gid, $rdev, $size, $atime,$mtime, $ctime, $blksize, $blocks) = stat(file);

The file can be either a file handle referring to a file you've opened or a file name. 
The stat function returns a list. 
The values returned from the stat function are listed in the following table.
The time values are returned as seconds from January 1, 1970.
If you don't have permission to read the file, lstat and stat will return an empty list.

Value       Holds
$dev        Device number of file system.
$inode      Inode number.
$mode       File mode (type and permissions).
$nlink      Number of hard links to the file.
$uid        Numeric user ID of file's owner.
$gid        Numeric group ID of file's owner.
$rdev       The device identifier device (special) files only.
$size       Total size of file, in bytes.
$atime      Time of last access.
$mtime      Time of last modification.
$ctime      Time of inode change.
$blksize    Preferred block size for file system I/O.
$blocks     Actual number of blocks allocated.

   
    
    
    
  








Related examples in the same category

1.Get return value from stat function
2.Get the file size
3.Get the length of a file
4.File statistics returned from the stat command
5.File stats
6.Checks the permissions of a file
7.Call stat function from file handle
8.Lists files in directory; then gets info on files with stat
9.The stat Function for Windows NT File Attributes