line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Any::Perl; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
3925
|
use strict; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
251
|
|
4
|
8
|
|
|
8
|
|
37
|
use warnings; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
214
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
36
|
use base 'Config::Any::Base'; |
|
8
|
|
|
|
|
41
|
|
|
8
|
|
|
|
|
1752
|
|
7
|
8
|
|
|
8
|
|
52
|
use File::Spec; |
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
177
|
|
8
|
8
|
|
|
8
|
|
37
|
use Cwd (); |
|
8
|
|
|
|
|
39
|
|
|
8
|
|
|
|
|
1449
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Config::Any::Perl - Load Perl config files |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Loads Perl files. Example: |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
{ |
19
|
|
|
|
|
|
|
name => 'TestApp', |
20
|
|
|
|
|
|
|
'Controller::Foo' => { |
21
|
|
|
|
|
|
|
foo => 'bar' |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
'Model::Baz' => { |
24
|
|
|
|
|
|
|
qux => 'xyzzy' |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 extensions( ) |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return an array of valid extensions (C, C). |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub extensions { |
37
|
10
|
|
|
10
|
1
|
25
|
return qw( pl perl ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 load( $file ) |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Attempts to load C<$file> as a Perl file. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub load { |
47
|
17
|
|
|
17
|
1
|
15091
|
my $class = shift; |
48
|
17
|
|
|
|
|
45
|
my $file = shift; |
49
|
|
|
|
|
|
|
|
50
|
17
|
|
|
|
|
29
|
my( $exception, $content ); |
51
|
|
|
|
|
|
|
{ |
52
|
17
|
|
|
|
|
38
|
local $@; |
|
17
|
|
|
|
|
28
|
|
53
|
|
|
|
|
|
|
# previously this would load based on . being in @INC, and wouldn't |
54
|
|
|
|
|
|
|
# trigger taint errors even if '.' probably should have been considered |
55
|
|
|
|
|
|
|
# tainted. untaint for backwards compatibility. |
56
|
17
|
|
|
|
|
42622
|
my ($cwd) = Cwd::cwd() =~ /\A(.*)\z/s; |
57
|
17
|
|
|
|
|
6401
|
$content = do File::Spec->rel2abs($file, $cwd); |
58
|
17
|
100
|
66
|
|
|
702
|
$exception = $@ || $! |
59
|
|
|
|
|
|
|
if !defined $content; |
60
|
|
|
|
|
|
|
} |
61
|
17
|
100
|
|
|
|
222
|
die $exception if $exception; |
62
|
|
|
|
|
|
|
|
63
|
11
|
|
|
|
|
146
|
return $content; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 AUTHOR |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Brian Cassidy |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Copyright 2006-2016 by Brian Cassidy |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
75
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SEE ALSO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * L |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * L |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |