Subject: | RegularExpressions::ProhibitUnusedCapture false positive when capture used in an else branch |
Date: | Thu, 28 Jul 2011 18:45:27 +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
$ perlcritic -3
use strict;
use warnings;
# false positive: RegularExpressions::ProhibitUnusedCapture
my($ip, @fields);
if ($ip !~ /^(.*?)::(.*)\z/sx) {
@fields = split(/:/x, $ip);
} else {
my($before,$after) = ($1,$2);
# ...
}
Only use a capturing group if you plan to use the captured value at line 6, column 14. See page 252 of PBP. (Severity: 3)
Mark