
- Perl 基礎知識
- Perl 主頁
- Perl 介紹
- Perl 環境
- Perl 語法概覽
- Perl 資料型別
- Perl 變數
- Perl 標量
- Perl 陣列
- Perl 雜湊
- Perl IF...ELSE
- Perl 迴圈
- Perl 運算子
- Perl 日期和時間
- Perl 子例程
- Perl 引用
- Perl 格式
- Perl 檔案 I/O
- Perl 目錄
- Perl 錯誤處理
- Perl 特殊變數
- Perl 編碼標準
- Perl 正則表示式
- Perl 傳送電子郵件
Perl lstat 函式
說明
此函式對 FILEHANDLE 或 EXPR 或 $_ 引用的檔案執行與 stat 函式相同的測試
如果檔案是一個符號連結,它返回指向連結的資訊,而不是指向的檔案的資訊。否則,它返回檔案的資訊。
語法
以下是此函式的簡單語法 −
lstat FILEHANDLE lstat EXPR lstat
返回值
此函式在列表上下文中返回一個 13 元素的列表,這些欄位如下 −
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
注 − 紀元為 1970 年 1 月 1 日格林威治時間協調時 00:00。
示例
以下是顯示其基本用法的示例程式碼 −
#!/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
廣告