- 基本 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
- Perl - 套接字程式設計
- Perl - 面向物件
- Perl - 資料庫訪問
- Perl - CGI 程式設計
- Perl - 包和模組
- Perl - 程序管理
- Perl - 嵌入式文件
- Perl - 函式引用
- 有用的 Perl 資源
- Perl - 答疑解惑
- Perl - 快速指南
- 有用的 Perl 資源
- Perl - 討論
Perl stat 函式
描述
此函式返回一個包含 13 個元素的陣列,給出由 FILEHANDLE、EXPR 或 $_ 指定的檔案狀態資訊。下面表中顯示了返回的值列表。如果在標量上下文中使用,則失敗時返回 0,成功時返回 1。
請注意,其中一些元素的支援與系統相關。請檢視文件以瞭解完整列表。
Element Description 0 Device number of file system 1 Inode number 2 File mode (type and permissions) 3 Number of (hard) links to the file 4 Numeric user ID of file.s owner 5 Numeric group ID of file.s owner 6 The device identifier (special files only) 7 File size, in bytes 8 Last access time since the epoch 9 Last modify time since the epoch 10 Inode change time (not creation time!) since the epoch 11 Preferred block size for file system I/O 12 Actual number of blocks allocated
語法
下面是此函式的簡單語法 -
stat FILEHANDLE stat EXPR stat
返回值
此函式返回 ARRAY,($device, $inode, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks)
示例
下面是展示其基本用法的示例程式碼 -
#!/usr/bin/perl -w
($device, $inode, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
$ctime, $blksize, $blocks) = stat("/etc/passwd");
print("stat() $device, $inode, $ctime\n");
當執行以上程式碼時,它將產生以下結果 -
stat() 2065, 5374250, 1508051555
perl_function_references.htm
廣告