Perl-lstat
提供:Dev Guides
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
注-エポックは、GMT 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;