line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package punctuation; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1681
|
use B::Utils 'walkoptree_filtered', 'opgrep'; |
|
1
|
|
|
|
|
8206
|
|
|
1
|
|
|
|
|
160
|
|
5
|
1
|
|
|
1
|
|
15
|
use B::Utils 0.03; |
|
1
|
|
|
|
|
36
|
|
|
1
|
|
|
|
|
915
|
|
6
|
|
|
|
|
|
|
$VERSION = 0.02; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %punct = (gv => '', gvsv => '$', gvav => '@', gvhv => '%', |
9
|
|
|
|
|
|
|
rv2sv => '$', rv2av => '@', rv2hv => '%', |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
my %packages; |
12
|
|
|
|
|
|
|
my @roots = (); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
CHECK { |
15
|
1
|
|
|
1
|
|
3
|
my $bad; |
16
|
|
|
|
|
|
|
|
17
|
1
|
50
|
|
|
|
13
|
if (%interesting_package) { |
18
|
1
|
|
|
|
|
8
|
my %all_roots = B::Utils::all_roots(); |
19
|
1
|
50
|
|
|
|
67372
|
push @roots, $all_roots{'__MAIN__'} if $interesting_package{main}; |
20
|
1
|
|
|
|
|
64
|
for my $k (keys %all_roots) { |
21
|
764
|
|
|
|
|
2568
|
my ($pack, $name) = ($k =~ /(.*)::(.*)/); |
22
|
764
|
50
|
66
|
|
|
3413
|
next unless defined $pack && $interesting_package{$pack}; |
23
|
0
|
|
|
|
|
0
|
push @roots, $all_roots{$k}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# print "List of roots has ", scalar(@roots), " entries.\n"; |
28
|
|
|
|
|
|
|
walkoptree_filtered( |
29
|
|
|
|
|
|
|
$_, |
30
|
|
|
|
|
|
|
# filter |
31
|
31
|
|
|
|
|
2072
|
sub { opgrep({name => [qw(gv gvsv gvav gvhv)]}, @_); |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
# callback |
34
|
2
|
|
|
|
|
125
|
sub { my $op = shift; |
35
|
2
|
|
|
|
|
12
|
my $gv = $op->gv; |
36
|
2
|
|
|
|
|
14
|
my ($file, $line, $name) = ($gv->FILE, $gv->LINE, $gv->NAME); |
37
|
2
|
|
|
|
|
19
|
my $safename = $gv->SAFENAME; |
38
|
|
|
|
|
|
|
# print STDERR "NAME: $name $safename\n"; |
39
|
2
|
50
|
|
|
|
14
|
return if $name =~ /^\w/; |
40
|
0
|
|
0
|
|
|
0
|
my $punct = $punct{$op->name} || $punct{$op->next->name}; |
41
|
0
|
|
|
|
|
0
|
B::Utils::carp("Illegal punctuation variable $punct$safename"); |
42
|
0
|
|
|
|
|
0
|
$bad++; |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
# user |
45
|
|
|
|
|
|
|
) |
46
|
1
|
|
|
|
|
56
|
for @roots; |
47
|
1
|
50
|
|
|
|
131693
|
exit 119 if $bad; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub unimport { |
51
|
1
|
|
|
1
|
|
12
|
my $pack = shift; |
52
|
1
|
|
|
|
|
2
|
my $caller = caller; |
53
|
1
|
|
|
|
|
4
|
for my $arg (@_) { |
54
|
0
|
0
|
|
|
|
0
|
if ($arg eq 'anon') { |
55
|
0
|
|
|
|
|
0
|
push @roots, B::Utils::anon_subs(); |
56
|
|
|
|
|
|
|
} else { |
57
|
0
|
|
|
|
|
0
|
require Carp; |
58
|
0
|
|
|
|
|
0
|
Carp::Croak("$pack: Unknown parameter $_"); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
1
|
50
|
|
|
|
7
|
if (@_ == 0) { |
62
|
|
|
|
|
|
|
# print "Package ($caller) is now interesting.\n"; |
63
|
1
|
|
|
|
|
1096
|
$interesting_package{$caller} = 1; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
punctuation - Forbid uses of punctuation variables |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SYNOPSIS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
no punctuation; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
no punctuation 'anon'; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Use of the C pragma in a package forbids all uses of |
82
|
|
|
|
|
|
|
punctuation variables such as C<$">, C<$!>, C<$^O>, and so on in |
83
|
|
|
|
|
|
|
named subroutines defined in that package. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
C forbids the use of punctuation variables in all anonymous subroutines in the program. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
C |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 EXPORT |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
None by default. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Mark Jason Dominus, C |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 PREREQUISITE |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Requires C. However, the version of C available |
100
|
|
|
|
|
|
|
on CPAN at this time of this writing (version 0.02) has many bugs. |
101
|
|
|
|
|
|
|
You may obtain a corrected copy of 0.02 from |
102
|
|
|
|
|
|
|
C . |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 TODO |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Probably none of it works the way you wish it would, but as they say: |
107
|
|
|
|
|
|
|
If a thing's not worth doing at all, it's not worth doing well. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SEE ALSO |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|