line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
98886
|
use 5.009003; |
|
1
|
|
|
|
|
5
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
71
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package namespace::lexical; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
495
|
use Package::Stash (); |
|
1
|
|
|
|
|
8196
|
|
|
1
|
|
|
|
|
119
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
1
|
50
|
|
1
|
|
3
|
if (eval { require Lexical::Sub; 1 }) { |
|
1
|
|
|
|
|
177
|
|
|
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
|
|
|
|
|
432
|
require Lexical::Importer; |
19
|
1
|
|
|
|
|
8725
|
*_LEXICAL_SUB_CLASS = sub () { 'Lexical::Importer' }; |
20
|
1
|
|
|
|
|
189
|
*_LEXICAL_SUB_IMPORT_METHOD = sub () { '_import_lex_sub' }; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub import { |
25
|
1
|
|
|
1
|
|
8
|
my $class = shift; |
26
|
1
|
|
|
|
|
3
|
my $for = caller; |
27
|
1
|
|
|
|
|
13
|
my $stash = 'Package::Stash'->new($for); |
28
|
1
|
|
|
|
|
15
|
my $subs = $stash->get_all_symbols('CODE'); |
29
|
1
|
|
|
|
|
8
|
for my $name (sort keys %$subs) { |
30
|
1
|
|
|
|
|
4
|
$class->lexicalize($stash, $name, $subs->{$name}); |
31
|
|
|
|
|
|
|
} |
32
|
1
|
|
|
|
|
37
|
return; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub lexicalize { |
36
|
1
|
|
|
1
|
1
|
2
|
my $class = shift; |
37
|
1
|
|
|
|
|
12
|
my ($stash, $name, $coderef) = @_; |
38
|
1
|
50
|
|
|
|
4
|
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
|
|
|
|
|
9
|
$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
|
|
|
|
|
31
|
|
45
|
1
|
|
|
|
|
5
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |