in reply to Re: Re: file testing is hard
in thread file testing is hard

True, that.

In practice, I usually dispense with such filetests and just go straight for the open(). But then, I usually program on win32, where that's okay.

I seem to remember, though, that it's perfectly legal to open directory entries, block/char special files, etc on a UNIX filesystem. I included those specific tests to cover those cases. You (probably) don't want to read your persistent INI from a serial port, nor save it to a directory inode.

I didn't check for read/write permissions, because open() will do that. Also, it encourages checking the return value of open(), which was most of my point -- it avoids code like this:
if ( -r $file ) { open(FILE, $file); # hmmm... is the file open or not? my @contents = <FILE>; close FILE; # process @contents; }