Subject: | Close filehandles as soon as possible after opening (possibly false positive) |
MULTIPLE FALSE POSITIVES
Close filehandles as soon as possible after opening them at line 8,
column 5. See page 209 of PBP.
3 is not one of the allowed literal values (0, 1, 2). Use the Readonly
module or the "constant" pragma instead at line 30, column 16. Unnamed
numeric literals make code less maintainable.
4 is not one of the allowed literal values (0, 1, 2). Use the Readonly
module or the "constant" pragma instead at line 30, column 19. Unnamed
numeric literals make code less maintainable.
5 is not one of the allowed literal values (0, 1, 2). Use the Readonly
module or the "constant" pragma instead at line 30, column 22. Unnamed
numeric literals make code less maintainable.
[An excerpt, not runnable "as is"]
1 #!/usr/bin/perl
2 use strict;
3
4 sub Read ($)
5 {
6 my $file = shift;
7
8 open my $FH, "<", $file or return;
9
10 my (%tabs, %div);
11
12 while ( <$FH> )
13 {
14 chomp;
15
16 if ( /^([[:space:]]+)/ )
17 {
18 my $len = length TabToSpaces $1;
19
20 $tabs{$len}++;
21 $TABS{$len}++;
22
23 if ( $len == 2 )
24 {
25 $div{2}++;
26 $DIV{2}++;
27 }
28 elsif ( $len > 2 and $len <= $INDENT_MAX)
29 {
30 for my $div (3, 4, 5)
31 {
32 unless ( $len % $div )
33 {
34 $div{$div}++;
35 $DIV{$div}++;
36 last;
37 }
38 }
39 }
40 }
41 }
42
43 close $FH or warn "Close failure $ERRNO";
44
45 if ( $verb == 1 )
46 {
47 print $file, "\n";
48 }
49 elsif ( $verb > 1 )
50 {
51 Print \%tabs, "$file BY INDENT";
52 Print \%div, "$file BY INDENTATION LEVEL (multiples
of)";
53 }
54 }