In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Chris Thorman) wrote:
> [Why do I want to use stat() instead of -l? Because I am indexing an entire
> disk's worth of files and want to execute the minimum number of stat() calls.
> Certainly I don't want to have to use -l with a path on every file -- I want
> to get the mode and other stat values once and then use the sys/stat.h (use
> Fcntl) macros S_ISLNK, S_ISDIR, etc.]
The _ filehandle can be used to apply the file test operators to the
last file that was referenced by any of them, or by stat. For example,
you can do something like this:
if (-f $file) {
## do something here
} elsif (-d _) {
## do something here
}
The -d operator uses the same stat buffer as the -f operation, without
querying the file system again. This is documented in perldoc -f stat.
--
Kevin Michael Vail | Dogbert: That's circular reasoning.
[EMAIL PROTECTED] | Dilbert: I prefer to think of it as no loose ends.
http://www.vaildc.net/kevin/