blob: d64949b67205412ced30230dd1877e66b11a35d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#!/usr/bin/env perl
#
# $FML$
#
use strict;
my $in_sub = 0;
my $in_head = 0;
my $defined = 0;
my $close = 0;
my $count = 0;
my $buf = '';
my $prev_argv = '';
my $prev_line = '';
while (<>) {
# reset the line number counter
if ($prev_argv ne $ARGV) {
$count = 0;
$prev_argv = $ARGV;
}
$count++;
if (/^\s*\#/ || /^\s*$/) {
$prev_line = $_;
next;
}
# ignore documents
if (/^\=\w+/) {
$prev_line = $_;
$in_head = 1;
$in_head = 0 if /^\=cut/;
next;
}
if ($in_head) {
$prev_line = $_;
next;
}
#
# 1. check the usage of open() and close() under not check of defined()
#
if (/defined/) { $defined = 1;}
if (/\$\S+\-\>(close|open)/ && (!/^sub /) && (!/^=head/) && (!/\$self/)) {
unless ($defined) {
$buf .= " ===> ". $_;
print "<<<($ARGV $count)\n", $buf, "\n>>>\n\n";
}
}
#
# 2. check FNF
#
if (/^sub / && ($prev_line !~ /^\#/)) {
print "$ARGV $count (FNF)> $_";
}
#
# last resort: logging buffer
#
if (/^sub |^\}/) {
undef $buf;
$in_sub = 1;
$defined = 0;
}
if ($in_sub) {
$buf .= $_;
}
$prev_line = $_;
}
|