|
|
ru.perl- RU.PERL ---------------------------------------------------------------------- From : Alexander V. Gaiduk 2:5020/400 27 Aug 2002 10:37:53 To : Yuri Mashkovtsev Subject : Hа: самый старый файл в каталоге -------------------------------------------------------------------------------- > > RP> Hужно получить имя самого стаpого файла в каталоге (учитывать и дату и > > RP> вpемя создания). Как бы это сделать? > > Просто так не получишь, смотри в сторону stat. > > И что он там увидит ? $имя_файла = "/etc/passwd"; $время_последней_модификации_файла = (stat($имя_файла))[9]; время дается в секундах с 1 января 1970 года. а вообще, выполнив команду "perldoc -f stat", ты бы увидел примерно следующее: stat FILEHANDLE stat EXPR stat Returns a 13-element list giving the status info for a file, either the file opened via FILEHANDLE, or named by EXPR. If EXPR is omitted, it stats $_. Returns a null list if the stat fails. Typically used as follows: ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename); Not all fields are supported on all filesystem types. Here are the meaning of the fields: 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 (NOT creation time!) in seconds since the epoch 11 blksize preferred block size for file system I/O 12 blocks actual number of blocks allocated (The epoch was at 00:00 January 1, 1970 GMT.) ну и так далее... --- ifmail v.2.15dev5 * Origin: LesoBANK (2:5020/400) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.perl/11999a566d510.html, оценка из 5, голосов 10
|