From 1e5163809eff116ff1b34956562e1f6ec0bbf370 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 6 May 2014 01:33:17 +0200 Subject: perl: Fix unused capture groups false positives These are false positives, as when there's no match perl will leave the subpattern variables untouched. We'll just use the opportunity to unconfuse perlcritic, making some of those variable usages more clear by using intermediate variables. Fixes RegularExpressions::ProhibitUnusedCapture. Warned-by: perlcritic --- scripts/Dpkg/Control/HashCore.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'scripts/Dpkg/Control/HashCore.pm') diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm index 6d6f1c554..dfd5e5531 100644 --- a/scripts/Dpkg/Control/HashCore.pm +++ b/scripts/Dpkg/Control/HashCore.pm @@ -202,16 +202,17 @@ sub parse { $paraborder = 0; if (m/^(\S+?)\s*:\s*(.*)$/) { $parabody = 1; - if ($1 =~ m/^-/) { + my ($name, $value) = ($1, $2); + if ($name =~ m/^-/) { $self->parse_error($desc, _g('field cannot start with a hyphen')); } - if (exists $self->{$1}) { + if (exists $self->{$name}) { unless ($$self->{allow_duplicate}) { - $self->parse_error($desc, _g('duplicate field %s found'), $1); + $self->parse_error($desc, _g('duplicate field %s found'), $name); } } - $self->{$1} = $2; - $cf = $1; + $self->{$name} = $value; + $cf = $name; } elsif (m/^\s(\s*\S.*)$/) { my $line = $1; unless (defined($cf)) { -- cgit v1.2.3