hi,

I'm reading the book of "automating system administration with perl" and
having doubts about this code snippets about file health check.

# attempt to read the directory entry for this file
my @stat = stat($name);
if ( !$stat[4] && !$stat[5] && !$stat[6] && !$stat[7] && !$stat[8] ) {
return 0;                        # according to the code context, here it
is saying the file is NOT ok
}

here $name refers to the file name and it's checking the stat of this file.

stat[4:8] refers to the following from the "perldoc -f stat"

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

so here the code is actually saying if all the above entries is 0 or
undefined, then we declare this file to be NOT ok .
and my question would be about this logic, why are we checking all of them
with a AND relationship rather than OR, or maybe something else(like
checking all the 0-12 entries) ?

Thanks
Frank

Reply via email to