Subject: | ProhibitUnusedVars isn't finding all unused variables. |
Saving this to the file critic.pl:
my %val;
while ( my ( $k, $v ) = each %hash ) {
my $k = $v;
}
And running this:
perlcritic --single-policy ProhibitUnusedVariables critic.pl
Results in:
"%val" is declared but not used at line 1, column 1. Unused variables clutter code and make
it harder to read. (Severity: 3)
The %hash and the first $k are not found.
The following has an unused variable which is not detected:
sub foo {
my $x = 1;
}
The following will also fail to find either unused variable:
sub foo {
my $x;
}
sub bar {
my $x;
}
Cheers,
Ovid