Subject: | RegularExpressions::ProhibitCaptureWithoutTest prohibits local($1,$2,$3) |
Date: | Thu, 28 Jul 2011 18:34:32 +0200 |
To: | bug-Perl-Critic [...] rt.cpan.org |
From: | Mark Martinec <Mark.Martinec [...] ijs.si> |
FreeBSD 8.2, perl 5.14.1, Perl::Critic 1.116
As best practices the $1, $2, $3, ... globals are commonly localized within
inner routines. One reason for this is to avoid a perl #67962 taint bug,
the other is to protect a caller from unexpected side effects of the called code.
The RegularExpressions::ProhibitCaptureWithoutTest test unwarrantly claims
that local($1,$2,$3) is a case of a 'Capture variable used outside conditional':
$ perlcritic -3
use strict;
use warnings;
# false positive: RegularExpressions::ProhibitCaptureWithoutTest
local($1,$2,$3); # workaround for a perl bug #67962, best practices
if (/(.)(.)(.)/x) {
my($a1,$a2,$a3) = ($1,$2,$3);
# ...
}
Capture variable used outside conditional at line 5, column 9. See page 253 of PBP. (Severity: 3)
Capture variable used outside conditional at line 5, column 12. See page 253 of PBP. (Severity: 3)
Capture variable used outside conditional at line 5, column 15. See page 253 of PBP. (Severity: 3)
Mark