| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pod::Constant; |
|
2
|
|
|
|
|
|
|
our $VERSION = 0.1; |
|
3
|
|
|
|
|
|
|
#PODNAME: Pod::Constant |
|
4
|
|
|
|
|
|
|
#ABSTRACT: source constants from POD to avoid repetition |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
18
|
|
|
18
|
|
232159
|
use 5.005; |
|
|
18
|
|
|
|
|
90
|
|
|
|
18
|
|
|
|
|
738
|
|
|
8
|
18
|
|
|
18
|
|
99
|
use warnings; |
|
|
18
|
|
|
|
|
36
|
|
|
|
18
|
|
|
|
|
573
|
|
|
9
|
18
|
|
|
18
|
|
101
|
use strict; |
|
|
18
|
|
|
|
|
39
|
|
|
|
18
|
|
|
|
|
688
|
|
|
10
|
18
|
|
|
18
|
|
92
|
use Carp; |
|
|
18
|
|
|
|
|
32
|
|
|
|
18
|
|
|
|
|
1754
|
|
|
11
|
18
|
|
|
18
|
|
117
|
use Scalar::Util qw(looks_like_number); |
|
|
18
|
|
|
|
|
30
|
|
|
|
18
|
|
|
|
|
1804
|
|
|
12
|
18
|
|
|
18
|
|
41842
|
use Text::Balanced qw(extract_delimited); |
|
|
18
|
|
|
|
|
448989
|
|
|
|
18
|
|
|
|
|
2141
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
BEGIN { |
|
15
|
18
|
|
|
18
|
|
196
|
use Pod::Parser; |
|
|
18
|
|
|
|
|
33
|
|
|
|
18
|
|
|
|
|
949
|
|
|
16
|
18
|
|
|
18
|
|
3709
|
our @ISA = qw(Pod::Parser); |
|
17
|
|
|
|
|
|
|
}; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub import { |
|
20
|
18
|
|
|
18
|
|
311
|
my $caller = caller; |
|
21
|
18
|
|
|
|
|
457
|
my ($class, @args) = @_; |
|
22
|
18
|
|
|
|
|
68
|
my $pod_source = $0; |
|
23
|
|
|
|
|
|
|
|
|
24
|
18
|
|
|
|
|
517
|
my $parser = $class->new; |
|
25
|
18
|
|
|
|
|
175
|
$parser->{vars} = {}; |
|
26
|
18
|
|
|
|
|
6528
|
$parser->parse_from_file($pod_source, undef); |
|
27
|
|
|
|
|
|
|
|
|
28
|
12
|
|
|
|
|
19
|
my %vars = %{$parser->{vars}}; |
|
|
12
|
|
|
|
|
79
|
|
|
29
|
12
|
100
|
100
|
|
|
123
|
my @export = (@args && lc $args[0] eq ':all') ? keys %vars : @args; |
|
30
|
|
|
|
|
|
|
|
|
31
|
12
|
|
|
|
|
31
|
for my $sym (@export) { |
|
32
|
44
|
100
|
|
|
|
164
|
$sym =~ /^[\w\$]/ or croak "Pod::Constant only supports scalar values"; |
|
33
|
43
|
|
|
|
|
100
|
$sym =~ s/^(\$)//; |
|
34
|
43
|
|
100
|
|
|
128
|
my $sigil = $1 || '$'; |
|
35
|
18
|
|
|
18
|
|
101
|
no strict 'refs'; |
|
|
18
|
|
|
|
|
44
|
|
|
|
18
|
|
|
|
|
11977
|
|
|
36
|
43
|
100
|
|
|
|
149
|
exists $vars{$sigil.$sym} or croak "No such constant '$sigil$sym' in POD"; |
|
37
|
41
|
|
|
|
|
59
|
*{$caller . '::' . $sym} = \$vars{$sigil . $sym}; |
|
|
41
|
|
|
|
|
212
|
|
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
9
|
|
|
|
|
20888
|
return; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Pod::Parser hooks |
|
44
|
|
|
|
|
|
|
sub textblock { |
|
45
|
58
|
|
|
58
|
0
|
105
|
my ($self, $block) = @_; |
|
46
|
58
|
|
|
|
|
6851
|
my $tree = $self->parse_text($block); |
|
47
|
58
|
|
|
|
|
385
|
my @children = $tree->children; |
|
48
|
58
|
|
|
|
|
208
|
while ( my $item = shift @children ) { |
|
49
|
94
|
100
|
66
|
|
|
2233
|
next unless ref $item && ref $item eq 'Pod::InteriorSequence'; |
|
50
|
56
|
50
|
|
|
|
290
|
next unless $item->cmd_name eq 'X'; |
|
51
|
|
|
|
|
|
|
|
|
52
|
56
|
|
|
|
|
330
|
my @ichildren = $item->parse_tree->children; |
|
53
|
56
|
50
|
|
|
|
142
|
next unless @ichildren == 1; |
|
54
|
56
|
50
|
|
|
|
280
|
next unless $ichildren[0] =~ /^\s*([\$\@%])?(\w*)\s*=\s*(.*)$/; |
|
55
|
56
|
|
|
|
|
165
|
my ($sigil, $var, $trailing) = ($1, $2, $3); |
|
56
|
56
|
|
100
|
|
|
121
|
$sigil ||= '$'; |
|
57
|
56
|
100
|
|
|
|
232
|
$sigil eq '$' or croak "Pod::Constant only supports scalar values"; |
|
58
|
53
|
|
|
|
|
83
|
$var = $sigil . $var; |
|
59
|
53
|
100
|
|
|
|
161
|
$trailing eq '' or croak "X<> tag should not include value"; |
|
60
|
52
|
|
|
|
|
70
|
my $text = shift @children; |
|
61
|
52
|
100
|
|
|
|
152
|
ref $text eq '' or croak "Invalid POD: X<> followed by another POD construct"; |
|
62
|
51
|
|
|
|
|
64
|
my $value = ''; |
|
63
|
|
|
|
|
|
|
|
|
64
|
51
|
100
|
|
|
|
207
|
if ( $text =~ /^\s*(['"`])/ ) { |
|
|
|
100
|
|
|
|
|
|
|
65
|
13
|
|
|
|
|
45
|
$value = extract_delimited( $text, $1 ); |
|
66
|
13
|
|
|
|
|
981
|
$value = substr $value, 1, -1; # strip quotes |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
elsif ($text =~ /^\s*(\S+)/) { |
|
69
|
37
|
|
|
|
|
66
|
$value = $1; |
|
70
|
|
|
|
|
|
|
# This is a manual list because [[:punct:]] includes / and _ |
|
71
|
37
|
|
|
|
|
78
|
$value =~ s/[!?,.:;]+$//; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# If it looks like a number, strip commas |
|
74
|
37
|
|
|
|
|
52
|
my $number = $value; |
|
75
|
37
|
|
|
|
|
55
|
$number =~ tr/,//d; |
|
76
|
37
|
100
|
|
|
|
174
|
if (looks_like_number($number)) { |
|
77
|
30
|
|
|
|
|
49
|
$value = $number; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
else { |
|
81
|
1
|
|
|
|
|
39
|
croak "No value provided for '$var'"; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
50
|
50
|
|
|
|
125
|
if ( exists $self->{vars}{$var} ) { |
|
85
|
0
|
0
|
|
|
|
0
|
$self->{vars}{$var} eq $value |
|
86
|
|
|
|
|
|
|
or croak "Variable '$var' specified twice with two different values"; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
else { |
|
89
|
50
|
|
|
|
|
3678
|
$self->{vars}{$var} = $value; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |