|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Pod::Licensizer;  | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
4
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
20703
 | 
 use strict;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
34
 | 
    | 
| 
5
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
5
 | 
 use warnings;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
25
 | 
    | 
| 
6
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
750
 | 
 use Pod::Abstract;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
314815
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
45
 | 
    | 
| 
7
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
1357
 | 
 use Log::Log4perl qw(:easy);  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
55648
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = "0.03";  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub new {  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
14
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
1
  
 | 
214
 | 
     my( $class, %options ) = @_;  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
16
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     my $self = {  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         pa       => undef,  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         file     => undef,  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         org_pod  => undef,  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         %options,  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     };  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
23
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
     bless $self, $class;  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
25
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     return $self;  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub load_file {  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
31
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
1
  
 | 
4578
 | 
     my( $self, $file ) = @_;  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
33
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
     $self->{ file }    = $file;  | 
| 
34
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24
 | 
     $self->{ pa }      = Pod::Abstract->load_file( $file );  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
36
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24903
 | 
     $self->{ org_pod } = $self->{ pa }->pod();  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
38
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3559
 | 
     return $self->{ pa };  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub modified {  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
44
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
0
  
 | 
0
 | 
     my( $self ) = @_;  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
46
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     return $self->{ org_pod } ne $self->{ pa }->pod();  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub write_file {  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
52
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
0
  
 | 
0
 | 
     my( $self, $file ) = @_;  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
54
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     if( !defined $file ) {  | 
| 
55
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         if( defined $self->{ file } ) {  | 
| 
56
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
             $file = $self->{ file };  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         } else {  | 
| 
58
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
             LOGWARN "No file defined";  | 
| 
59
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
             return  undef;  | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
63
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     if( ! open FILE, ">$file" ) {  | 
| 
64
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         ERROR "Can't open $file: $!";  | 
| 
65
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         return undef;  | 
| 
66
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
67
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
68
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     print FILE $self->{ pa }->pod();  | 
| 
69
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     close FILE;  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub as_string {  | 
| 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
75
 | 
8
 | 
 
 | 
 
 | 
  
8
  
 | 
  
0
  
 | 
278
 | 
     my( $self ) = @_;  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
77
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
46
 | 
     return $self->{ pa }->pod();  | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub author_patch {  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
83
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
0
  
 | 
34
 | 
     my( $self, $text, $opts ) = @_;  | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
85
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
18
 | 
     $opts = {} unless defined $opts;  | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
87
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
13
 | 
     if( $opts->{author_heading} ) {  | 
| 
88
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         $opts->{author_regex} = "^$opts->{author_heading}\$";  | 
| 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     } else {  | 
| 
90
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
         $opts->{author_regex} = '^AUTHORS?$';  | 
| 
91
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
         $opts->{author_heading} = "AUTHOR";  | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
93
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
94
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
16
 | 
     return $self->section_patch( $opts->{author_heading},   | 
| 
95
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                                  $opts->{author_regex},  | 
| 
96
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                                  $text,  | 
| 
97
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                                  $opts );  | 
| 
98
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
99
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
100
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
101
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub license_patch {  | 
| 
102
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
103
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
0
  
 | 
6393
 | 
     my( $self, $text, $opts ) = @_;  | 
| 
104
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
105
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
14
 | 
     $opts = {} unless defined $opts;  | 
| 
106
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
16
 | 
     $opts->{license_heading} = "LICENSE" if !defined $opts->{license_heading};  | 
| 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
108
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
     return $self->section_patch( $opts->{license_heading},   | 
| 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                                  "^$opts->{license_heading}\$",  | 
| 
110
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                                  $text,  | 
| 
111
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                                  $opts );  | 
| 
112
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
113
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
114
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
115
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub section_patch {  | 
| 
116
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################  | 
| 
117
 | 
8
 | 
 
 | 
 
 | 
  
8
  
 | 
  
0
  
 | 
19
 | 
     my( $self, $heading, $regex, $text, $opts ) = @_;  | 
| 
118
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
119
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
23
 | 
     my $info_prefix = "";  | 
| 
120
 | 
8
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
23
 | 
     $info_prefix = "(dryrun) " if $opts->{ dryrun };  | 
| 
121
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
122
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
23
 | 
     while( $text !~ /\n\n$/ ) {  | 
| 
123
 | 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
52
 | 
         $text = "$text\n";  | 
| 
124
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
125
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
126
 | 
8
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
24
 | 
     $text =~ s/^/    /gm if exists $opts->{mode} and   | 
| 
127
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $opts->{mode} eq "verbatim";  | 
| 
128
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
129
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36
 | 
     my($section_head) = $self->{pa}->select("/head1[\@heading =~ {$regex}]");  | 
| 
130
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
131
 | 
8
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
10034
 | 
     if( $opts->{ clear } ) {  | 
| 
132
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         if( defined $section_head ) {  | 
| 
133
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
             INFO "${info_prefix}deleting section $heading from $self->{ file }";  | 
| 
134
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
             if( ! $opts->{ dryrun } ) {  | 
| 
135
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
                 $section_head->detach();  | 
| 
136
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
137
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
138
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         return 1;  | 
| 
139
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
140
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
141
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
40
 | 
     my $section_new = Pod::Abstract->load_string( $text );  | 
| 
142
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
143
 | 
8
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
8035
 | 
     if( !defined $section_head ) {  | 
| 
144
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
         $section_head = Pod::Abstract->load_string(   | 
| 
145
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             "=head1 $heading\n\nBlah.\n\n" );  | 
| 
146
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
           # skip the root  | 
| 
147
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7706
 | 
         ($section_head) = $section_head->children();  | 
| 
148
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
149
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
           # find the last =head1  | 
| 
150
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
82
 | 
         my( $last_head1 ) = reverse $self->{pa}->select("/head1");  | 
| 
151
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
1012
 | 
         $last_head1 = $self->{pa} unless defined $last_head1;  | 
| 
152
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
153
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
16
 | 
             $section_head->insert_after( $last_head1 );  | 
| 
154
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
155
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
156
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
261
 | 
     INFO "${info_prefix}adding section $heading to $self->{ file }";  | 
| 
157
 | 
8
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
123
 | 
     if( ! $opts->{ dryrun } ) {  | 
| 
158
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
28
 | 
         $section_head->clear();  | 
| 
159
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
823
 | 
         $section_head->push( $section_new );  | 
| 
160
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
161
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
162
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
163
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
164
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
165
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |