The File::stat module provides a method interface to Perl's built-in stat and lstat functions by replacing them with versions that return a File::stat object (or undef on failure). This object has methods that return the like-named structure field name from the traditional stat(2) syscall; namely, dev, ino, mode, nlink, uid, gid, rdev, size, atime, mtime, ctime, blksize, and blocks. You may also import the structure fields into your own namespace as regular variables using the ":FIELDS" import tag. (This still overrides your stat and lstat built-ins.) These fields show up as scalar variables named with a "st_" in front of the field name. That is, the $st_dev variable corresponds to the $st->dev method.use File::stat; $st = stat($file) or die "Can't stat $file: $!"; if ($st->mode & 0111 and $st->nlink > 1)) { print "$file is executable with many links\n"; } use File::stat ":FIELDS"; stat($file) or die "Can't stat $file: $!"; if ($st_mode & 0111 and $st_nlink > 1) ) { print "$file is executable with many links\n"; } @statinfo = CORE::stat($file); # Access overridden built-in.
Copyright © 2001 O'Reilly & Associates. All rights reserved.
HIVE: All information for read only. Please respect copyright! |