line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Defaults::Modern::Define; |
2
|
|
|
|
|
|
|
$Defaults::Modern::Define::VERSION = '0.010001'; |
3
|
1
|
|
|
1
|
|
4
|
use strictures 2; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
38
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for Pod::Coverage .* |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Forked from TOBYINK's PerlX::Define, copyright Toby Inkster |
10
|
|
|
|
|
|
|
# (... to avoid the Moops dep) |
11
|
|
|
|
|
|
|
# This probably goes away if PerlX::Define gets pulled out later. |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
200
|
use Carp (); |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
13
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
4
|
use B (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
16
|
1
|
|
|
1
|
|
367
|
use Keyword::Simple (); |
|
1
|
|
|
|
|
23188
|
|
|
1
|
|
|
|
|
263
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub import { |
19
|
8
|
|
|
8
|
|
991
|
shift; |
20
|
8
|
100
|
|
|
|
25
|
if (@_) { |
21
|
2
|
|
|
|
|
3
|
my ($name, $val) = @_; |
22
|
2
|
|
|
|
|
5
|
my $pkg = caller; |
23
|
2
|
50
|
|
|
|
7
|
my $code = ref $val ? |
24
|
|
|
|
|
|
|
qq[package $pkg; sub $name () { \$val }; 1;] |
25
|
2
|
|
|
|
|
9
|
: qq[package $pkg; sub $name () { ${\ B::perlstring($val) } }; 1;]; |
26
|
2
|
|
|
|
|
3
|
local $@; |
27
|
2
|
50
|
33
|
|
|
147
|
eval $code and not $@ or Carp::croak "eval: $@"; |
28
|
|
|
|
|
|
|
return |
29
|
2
|
|
|
|
|
124
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Keyword::Simple::define( define => sub { |
32
|
2
|
|
|
2
|
|
109
|
my ($line) = @_; |
33
|
2
|
50
|
|
|
|
19
|
my ($ws1, $name, $ws2, $equals) = |
34
|
|
|
|
|
|
|
($$line =~ m{\A([\n\s]*)(\w+)([\n\s]*)(=\>?)}s) |
35
|
|
|
|
|
|
|
or Carp::croak("Syntax error near 'define'"); |
36
|
2
|
|
|
|
|
6
|
my $len = length join '', $ws1, $name, $ws2, $equals; |
37
|
2
|
|
|
|
|
83
|
substr $$line, 0, $len, ";use Defaults::Modern::Define $name => "; |
38
|
6
|
|
|
|
|
46
|
}); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |