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