line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
98451
|
use 5.012; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
72
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package namespace::lexical; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
501
|
use Package::Stash (); |
|
1
|
|
|
|
|
8307
|
|
|
1
|
|
|
|
|
114
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
1
|
50
|
|
1
|
|
4
|
if (eval { require Lexical::Sub; 1 }) { |
|
1
|
|
|
|
|
184
|
|
|
0
|
|
|
|
|
0
|
|
14
|
0
|
|
|
|
|
0
|
*_LEXICAL_SUB_CLASS = sub () { 'Lexical::Sub' }; |
15
|
0
|
|
|
|
|
0
|
*_LEXICAL_SUB_IMPORT_METHOD = sub () { 'import' }; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
else { |
18
|
1
|
|
|
|
|
408
|
require Lexical::Importer; |
19
|
1
|
|
|
|
|
8680
|
*_LEXICAL_SUB_CLASS = sub () { 'Lexical::Importer' }; |
20
|
1
|
|
|
|
|
197
|
*_LEXICAL_SUB_IMPORT_METHOD = sub () { '_import_lex_sub' }; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub import { |
25
|
1
|
|
|
1
|
|
9
|
my $class = shift; |
26
|
1
|
|
|
|
|
2
|
my $for = caller; |
27
|
1
|
|
|
|
|
14
|
my $stash = 'Package::Stash'->new($for); |
28
|
1
|
|
|
|
|
15
|
my $subs = $stash->get_all_symbols('CODE'); |
29
|
1
|
|
|
|
|
7
|
for my $name (sort keys %$subs) { |
30
|
1
|
|
|
|
|
4
|
$class->lexicalize($stash, $name, $subs->{$name}); |
31
|
|
|
|
|
|
|
} |
32
|
1
|
|
|
|
|
38
|
return; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub lexicalize { |
36
|
1
|
|
|
1
|
1
|
2
|
my $class = shift; |
37
|
1
|
|
|
|
|
11
|
my ($stash, $name, $coderef) = @_; |
38
|
1
|
50
|
|
|
|
5
|
if (defined $stash) { |
39
|
1
|
50
|
|
|
|
3
|
$stash = 'Package::Stash'->new($stash) unless ref $stash; |
40
|
1
|
|
33
|
|
|
3
|
$coderef ||= $stash->get_symbol('&'.$name); |
41
|
1
|
|
|
|
|
8
|
$stash->remove_symbol('&'.$name); |
42
|
|
|
|
|
|
|
} |
43
|
1
|
50
|
|
|
|
4
|
die "coderef plz" unless defined $coderef; |
44
|
1
|
|
|
|
|
3
|
_LEXICAL_SUB_CLASS->${\ _LEXICAL_SUB_IMPORT_METHOD }($name, $coderef); |
|
1
|
|
|
|
|
14
|
|
45
|
1
|
|
|
|
|
3
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |