Subject: | InputOutput::ProhibitReadlineInForLoop mistakes glob for readline |
This test program:
#!/usr/bin/perl
# $Id: $
use warnings;
use strict;
use 5.010;
foreach (<*>) {}
saved as 'test' and checked with:
% perlcritic -1 --verbose "%f:%l:%c:%m [%p] (%e)\n" test
produces two warnings:
test:6:10:Glob written as <...> [BuiltinFunctions::RequireGlobFunction]
(See page 167 of PBP)
test:6:10:Readline inside "for" loop
[InputOutput::ProhibitReadlineInForLoop] (See page 211 of PBP)
The first one is correct. It is indeed a glob written as <...>. But
the second warning is incorrect.
I suggest changing InputOutput::ProhibitReadlineInForLoop to stop it
flagging these false positives. Whatever code is currently in
BuiltinFunctions::RequireGlobFunction to recognize a glob could be used
in the other rule to distinguish globs from filehandles.