|
|
ru.perl- RU.PERL ---------------------------------------------------------------------- From : Yuri Mashkovtsev 2:5036/22 27 Aug 2002 21:17:28 To : "Alexander V. Gaiduk" Subject : Re: Hа: самый старый файл в каталоге -------------------------------------------------------------------------------- >> > 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.) > ну и так далее... --- tin/1.5.8-20010221 ("Blue Water") (UNIX) (FreeBSD/4.3-RELEASE (i386)) * Origin: Biological Station (2:5036/22@fidonet) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.perl/1211966de777c.html, оценка из 5, голосов 10
|