Announcing perlcritic Policy ValuesAndExpressions::ProhibitFiletest_rwxRWX
Since several places in the Perl documentation caution against the use of the file access operators (
-r and friends), and since I was unable to find a
Perl::Critic policy dealing with this, I thought I would make one:
This policy is assigned to the
'bugs' theme. It has low severity because there are some uses of these operators that seem legitimate to me -- or at least I see no easy way to get around their use.
On the one hand, something like
-r $file or die "File $file not readable\n"; open my $handle, '<', $file;
is wrong several ways. On the other hand, it is hard to see how to implement
File::Which without the use of
-x. And in fact it does use
This policy has no configuration options. I can imagine a configuration option to allow some file access operators, but was unsure how much actual need there is for such an option. A configuration option to allow file access operators within the scope of a
use filetest 'access'; might be possible, but would certainly make the policy much more complex.
Maybe this policy should be in the
::BuiltinFunctions:: name space, but I decided to follow the precedent established by Kevin Ryde in his