line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::PL; |
2
|
3
|
|
|
3
|
|
73294
|
use 5.008001; |
|
3
|
|
|
|
|
20
|
|
3
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
70
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
128
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
16
|
use Carp (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
64
|
|
9
|
3
|
|
|
3
|
|
16
|
use Cwd (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
54
|
|
10
|
3
|
|
|
3
|
|
25
|
use File::Basename (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
627
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw/config_do/; |
13
|
|
|
|
|
|
|
our %CONFIG; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub import { |
16
|
8
|
|
|
8
|
|
13266
|
my ($pkg, @args) = @_; |
17
|
8
|
|
|
|
|
19
|
my $caller = caller; |
18
|
|
|
|
|
|
|
|
19
|
8
|
|
|
|
|
12
|
my @export; |
20
|
8
|
100
|
|
|
|
25
|
if (@args) { |
21
|
4
|
|
100
|
|
|
32
|
push @export, shift(@args) while $args[0] && $args[0] !~ '^:'; |
22
|
4
|
|
|
|
|
10
|
my %conf = @args; |
23
|
4
|
100
|
|
|
|
13
|
$CONFIG{path} = $conf{':path'} if exists $conf{':path'}; |
24
|
|
|
|
|
|
|
} |
25
|
8
|
100
|
|
|
|
29
|
@export = @EXPORT unless @export; |
26
|
|
|
|
|
|
|
|
27
|
8
|
|
|
|
|
20
|
for my $func (@export) { |
28
|
8
|
100
|
|
|
|
18
|
Carp::croak "'$func' is not exportable function" unless grep {$_ eq $func} @EXPORT; |
|
8
|
|
|
|
|
209
|
|
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
3
|
|
21
|
no strict 'refs'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
917
|
|
31
|
7
|
|
|
|
|
19
|
*{"$caller\::$func"} = \&$func; |
|
7
|
|
|
|
|
142
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub config_do($) { |
36
|
12
|
|
|
12
|
1
|
20955
|
my $config_file = shift; |
37
|
12
|
|
|
|
|
37
|
my (undef, $file,) = caller; |
38
|
|
|
|
|
|
|
|
39
|
12
|
|
|
|
|
45
|
my ($config, $errno) = do { |
40
|
12
|
|
|
|
|
554
|
local @INC = (Cwd::getcwd, File::Basename::dirname($file)); |
41
|
12
|
100
|
|
|
|
58
|
push @INC, $CONFIG{path} if defined $CONFIG{path}; |
42
|
|
|
|
|
|
|
|
43
|
12
|
|
|
|
|
2386
|
(scalar do $config_file, $!); |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
12
|
50
|
|
|
|
189
|
Carp::croak $@ if $@; |
47
|
12
|
100
|
|
|
|
265
|
Carp::croak $errno unless defined $config; |
48
|
10
|
100
|
|
|
|
28
|
unless (ref $config eq 'HASH') { |
49
|
1
|
|
|
|
|
167
|
Carp::croak "$config_file does not return HashRef."; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
9
|
100
|
|
|
|
47
|
wantarray ? %$config : $config; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
__END__ |