line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
8
|
|
|
8
|
|
62163
|
use 5.006; |
|
8
|
|
|
|
|
26
|
|
2
|
8
|
|
|
8
|
|
40
|
use strict; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
179
|
|
3
|
8
|
|
|
8
|
|
40
|
use warnings; |
|
8
|
|
|
|
|
22
|
|
|
8
|
|
|
|
|
425
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package ToolSet; |
6
|
|
|
|
|
|
|
# ABSTRACT: Load your commonly-used modules in a single import |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.03'; |
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
45
|
use Carp; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
3323
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#--------------------------------------------------------------------------# |
13
|
|
|
|
|
|
|
# package variables |
14
|
|
|
|
|
|
|
#--------------------------------------------------------------------------# |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %use_pragmas; |
17
|
|
|
|
|
|
|
my %no_pragmas; |
18
|
|
|
|
|
|
|
my %exports_of; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#--------------------------------------------------------------------------# |
21
|
|
|
|
|
|
|
# functions |
22
|
|
|
|
|
|
|
#--------------------------------------------------------------------------# |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub export { |
25
|
6
|
|
|
6
|
1
|
10946
|
my $class = shift; |
26
|
6
|
100
|
|
|
|
115
|
croak "Arguments to export() must be key/value pairs" |
27
|
|
|
|
|
|
|
if @_ % 2; |
28
|
5
|
|
|
|
|
17
|
my @spec = @_; |
29
|
5
|
|
|
|
|
10
|
my $caller = caller; |
30
|
5
|
|
|
|
|
15
|
$exports_of{$caller} = \@spec; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub import { |
34
|
18
|
|
|
18
|
|
7187
|
my ($class) = @_; |
35
|
18
|
|
|
|
|
46
|
my $caller = caller; |
36
|
18
|
100
|
|
|
|
60
|
if ( $use_pragmas{$class} ) { |
37
|
8
|
|
|
|
|
14
|
for my $p ( keys %{ $use_pragmas{$class} } ) { |
|
8
|
|
|
|
|
23
|
|
38
|
12
|
|
|
|
|
21
|
my $module = $p; |
39
|
12
|
|
|
|
|
24
|
$module =~ s{::}{/}g; |
40
|
12
|
|
|
|
|
22
|
$module .= ".pm"; |
41
|
12
|
|
|
|
|
256
|
require $module; |
42
|
12
|
|
|
|
|
129
|
$p->import( @{ $use_pragmas{$class}{$p} } ); |
|
12
|
|
|
|
|
141
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
18
|
100
|
|
|
|
74
|
if ( $no_pragmas{$class} ) { |
46
|
2
|
|
|
|
|
3
|
for my $p ( keys %{ $no_pragmas{$class} } ) { |
|
2
|
|
|
|
|
6
|
|
47
|
2
|
|
|
|
|
3
|
my $module = $p; |
48
|
2
|
|
|
|
|
4
|
$module =~ s{::}{/}g; |
49
|
2
|
|
|
|
|
4
|
$module .= ".pm"; |
50
|
2
|
|
|
|
|
7
|
require $module; |
51
|
2
|
|
|
|
|
3
|
$p->unimport( @{ $no_pragmas{$class}{$p} } ); |
|
2
|
|
|
|
|
10
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
18
|
100
|
|
|
|
36
|
my @exports = @{ $exports_of{$class} || [] }; |
|
18
|
|
|
|
|
109
|
|
55
|
18
|
|
|
|
|
62
|
while (@exports) { |
56
|
15
|
|
|
|
|
40
|
my ( $mod, $request ) = splice( @exports, 0, 2 ); |
57
|
|
|
|
|
|
|
|
58
|
15
|
|
|
|
|
22
|
my $evaltext; |
59
|
15
|
100
|
|
|
|
56
|
if ( !$request ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
60
|
5
|
|
|
|
|
36
|
$evaltext = "package $caller; use $mod"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif ( ref $request eq 'ARRAY' ) { |
63
|
5
|
|
|
|
|
11
|
my $args = join( q{ } => @$request ); |
64
|
5
|
|
|
|
|
16
|
$evaltext = "package $caller; use $mod qw( $args )"; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
elsif ( ref $request eq 'SCALAR' ) { |
67
|
1
|
|
|
|
|
3
|
my $args = $$request; |
68
|
1
|
|
|
|
|
3
|
$evaltext = "package $caller; use $mod $args"; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
elsif ( ref( \$request ) eq 'SCALAR' ) { |
71
|
3
|
|
|
|
|
7
|
$evaltext = "package $caller; use $mod qw( $request )"; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
1
|
|
|
|
|
78
|
croak "Invalid import specification for $mod"; |
75
|
|
|
|
|
|
|
} |
76
|
14
|
|
|
2
|
|
665
|
eval $evaltext; ## no critic |
|
2
|
|
|
2
|
|
11
|
|
|
2
|
|
|
1
|
|
3
|
|
|
2
|
|
|
1
|
|
62
|
|
|
2
|
|
|
1
|
|
1370
|
|
|
2
|
|
|
1
|
|
51
|
|
|
2
|
|
|
1
|
|
66
|
|
|
1
|
|
|
1
|
|
353
|
|
|
1
|
|
|
1
|
|
1927
|
|
|
1
|
|
|
1
|
|
9
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
|
1
|
|
|
|
|
332
|
|
|
1
|
|
|
|
|
635
|
|
|
1
|
|
|
|
|
40
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
85
|
|
|
1
|
|
|
|
|
353
|
|
|
1
|
|
|
|
|
538
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
199
|
|
|
1
|
|
|
|
|
102
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
223
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
100
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
77
|
14
|
100
|
|
|
|
422
|
croak "$@" if $@; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# import from a @EXPORT array in the ToolSet subclass |
81
|
|
|
|
|
|
|
{ |
82
|
8
|
|
|
8
|
|
57
|
no strict 'refs'; ## no critic |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
2418
|
|
|
15
|
|
|
|
|
27
|
|
83
|
15
|
|
|
|
|
36
|
for my $fcn ( @{"${class}::EXPORT"} ) { |
|
15
|
|
|
|
|
461
|
|
84
|
2
|
|
|
|
|
6
|
my $source = "${class}::${fcn}"; |
85
|
|
|
|
|
|
|
die "Can't import missing subroutine $source" |
86
|
2
|
100
|
|
|
|
4
|
if !defined *{$source}{CODE}; |
|
2
|
|
|
|
|
35
|
|
87
|
1
|
|
|
|
|
2
|
*{"${caller}::${fcn}"} = \&{$source}; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
2
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub set_strict { |
93
|
0
|
|
|
0
|
1
|
0
|
my ( $class, $value ) = @_; |
94
|
0
|
0
|
|
|
|
0
|
return unless $value; |
95
|
0
|
|
|
|
|
0
|
my $caller = caller; |
96
|
0
|
|
|
|
|
0
|
$use_pragmas{$caller}{strict} = []; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub set_warnings { |
100
|
0
|
|
|
0
|
1
|
0
|
my ( $class, $value ) = @_; |
101
|
0
|
0
|
|
|
|
0
|
return unless $value; |
102
|
0
|
|
|
|
|
0
|
my $caller = caller; |
103
|
0
|
|
|
|
|
0
|
$use_pragmas{$caller}{warnings} = []; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub set_feature { |
107
|
0
|
|
|
0
|
1
|
0
|
my ( $class, @args ) = @_; |
108
|
0
|
0
|
|
|
|
0
|
return unless @args; |
109
|
0
|
|
|
|
|
0
|
my $caller = caller; |
110
|
0
|
|
|
|
|
0
|
$use_pragmas{$caller}{feature} = [@args]; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub use_pragma { |
114
|
9
|
|
|
9
|
1
|
1396
|
my ( $class, $pragma, @args ) = @_; |
115
|
9
|
|
|
|
|
18
|
my $caller = caller; |
116
|
9
|
|
|
|
|
32
|
$use_pragmas{$caller}{$pragma} = [@args]; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub no_pragma { |
120
|
2
|
|
|
2
|
1
|
271
|
my ( $class, $pragma, @args ) = @_; |
121
|
2
|
|
|
|
|
4
|
my $caller = caller; |
122
|
2
|
|
|
|
|
7
|
$no_pragmas{$caller}{$pragma} = [@args]; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
__END__ |