- Perl Basics
- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- Perl - Variables
- Perl - Scalars
- Perl - Arrays
- Perl - Hashes
- Perl - IF...ELSE
- Perl - Loops
- Perl - Operators
- Perl - Date & Time
- Perl - Subroutines
- Perl - References
- Perl - Formats
- Perl - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl Advanced
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Useful Resources
- Perl - Discussion
Perl lstat Function
Description
This function performs the same tests as the stat function on FILEHANDLE or the file referred to by EXPR or $_
If the file is a symbolic link, it returns the information for the link, rather than the file it points to. Otherwise, it returns the information for the file.
Syntax
Following is the simple syntax for this function −
lstat FILEHANDLE lstat EXPR lstat
Return Value
This function returns a list of 13 elements in list context, these fields are as follows −
0 dev device number of filesystem 1 ino inode number 2 mode file mode (type and permissions) 3 nlink number of (hard) links to the file 4 uid numeric user ID of file's owner 5 gid numeric group ID of file's owner 6 rdev the device identifier (special files only) 7 size total size of file, in bytes 8 atime last access time in seconds since the epoch 9 mtime last modify time in seconds since the epoch 10 ctime inode change time in seconds since the epoch (*) 11 blksize preferred block size for file system I/O 12 blocks actual number of blocks allocated
NOTE − The epoch was at 00:00 January 1, 1970 GMT.
Example
Following is the example code showing its basic usage −
#!/usr/bin/perl -w $filename = "/tmp/test.pl"; ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize, $blocks) = lstat($filename); printf "File is %s,\n size is %s,\n perm %04o, mtime %s\n", $filename, $size, $mode & 07777, scalar localtime $mtime;
perl_function_references.htm
Advertisements