Getting Information on a File : stat « File « Perl

Perl
1. Array
2. CGI
3. Class
4. Data Type
5. Database
6. File
7. GUI
8. Hash
9. Language Basics
10. Network
11. Regular Expression
12. Report
13. Statement
14. String
15. Subroutine
16. System Functions
17. Win32
18. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Perl » File » stat 
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 11970.
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 (specialfiles 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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.