
Jasmine
Administrator
Apr 15, 2002, 11:09 AM
Post #2 of 5
(721 views)
|
Re: [benchivers] Reading Directories
[In reply to]
|
Can't Post
|
|
[url=http://www.perldoc.com/perl5.6.1/pod/func/stat.html]stat will get that info for you.
foreach my $file (@dir){ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat( $file ); print "filename - $file\n"; print "file size - $size\n"; print "modification date - $mtime\n"; # or, a slice will keep it simple: my ( $size, $mod_time ) = ( stat( $file ) )[7, 9]; } Here's the order in which stat returns data:
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
|