One of the Perl file test operators, (-r $file) attempts to tell you whether or not you could successfully open the file for reading. All it actually tells you is whether or not your effiective UserID or effective Group ID allows read access based on the permission bits on the file. There are still other things that might prevent you fom opening the file, not the least of which are Access Control Lists that some operating systems layer on top of the standard UNIX permissions.

It seems that -r came from the shell scripting languages. Namely bash and sh. Most of the file testing operators are commong across both perl and bash. Little snippet of code as an example:
#!/bin/bash
echo Checking ${1} permissions...
if [ -r ${1} ] then
    echo File is readable
else
    echo File is not readable
fi

#!/usr/bin/perl
print "Checking $ARGV[0] ...\n";
if (-r $ARGV[0])
{
    print "File is readable\n";
}
else
{
    print "File is not readable\n";
}

Log in or register to write something here or to contact authors.