line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Package::Alias; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Package::Alias::VERSION = '0.13'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Alias one namespace as another |
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
798611
|
use strict qw/vars subs/; |
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
310
|
|
8
|
7
|
|
|
7
|
|
51
|
use Carp; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
1178
|
|
9
|
7
|
|
|
7
|
|
205
|
use 5.006; # for INIT |
|
7
|
|
|
|
|
45
|
|
|
7
|
|
|
|
|
3670
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $BRAVE; |
12
|
|
|
|
|
|
|
our $DEBUG; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub alias { |
15
|
10
|
|
|
10
|
1
|
2254
|
my $class = shift; |
16
|
10
|
|
|
|
|
31
|
my %args = @_; |
17
|
|
|
|
|
|
|
|
18
|
10
|
|
|
|
|
67
|
while (my ($alias, $orig) = each %args) { |
19
|
13
|
100
|
100
|
|
|
19
|
if (scalar keys %{$alias . "::" } && ! $BRAVE) { |
|
13
|
|
|
|
|
119
|
|
20
|
1
|
|
|
|
|
312
|
carp "Cowardly refusing to alias over '$alias' because it's already in use"; |
21
|
1
|
|
|
|
|
10
|
next; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
12
|
|
|
|
|
14
|
*{$alias . "::"} = \*{$orig . "::"}; |
|
12
|
|
|
|
|
342
|
|
|
12
|
|
|
|
|
42
|
|
25
|
12
|
50
|
|
|
|
20250
|
print STDERR __PACKAGE__ . ": '$alias' is now an alias for '$orig'\n" |
26
|
|
|
|
|
|
|
if $DEBUG; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub import { |
31
|
9
|
|
|
9
|
|
78
|
my $class = shift; |
32
|
9
|
|
|
|
|
34
|
my %args = @_; |
33
|
|
|
|
|
|
|
|
34
|
9
|
|
|
|
|
60
|
while (my ($alias, $orig) = each %args) { |
35
|
12
|
|
|
|
|
21
|
my ($alias_pm, $orig_pm) = ($alias, $orig); |
36
|
12
|
|
|
|
|
31
|
foreach ($alias_pm, $orig_pm) { |
37
|
24
|
|
|
|
|
50
|
s/::/\//g; |
38
|
24
|
|
|
|
|
58
|
$_ .= '.pm'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
12
|
50
|
|
|
|
46
|
next if exists $INC{$alias_pm}; |
42
|
12
|
|
|
|
|
25
|
my $caller = caller; |
43
|
12
|
|
|
6
|
|
869
|
eval "{package $caller; use $orig;}"; |
|
6
|
|
|
4
|
|
5235
|
|
|
6
|
|
|
1
|
|
195
|
|
|
6
|
|
|
1
|
|
131
|
|
|
4
|
|
|
|
|
13042
|
|
|
4
|
|
|
|
|
245
|
|
|
4
|
|
|
|
|
85
|
|
|
1
|
|
|
|
|
753
|
|
|
1
|
|
|
|
|
30
|
|
|
1
|
|
|
|
|
21
|
|
|
1
|
|
|
|
|
2085
|
|
|
1
|
|
|
|
|
36
|
|
|
1
|
|
|
|
|
23
|
|
44
|
12
|
50
|
|
|
|
52
|
confess $@ if $@; |
45
|
12
|
|
|
|
|
164
|
$INC{$alias_pm} = $INC{$orig_pm}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
9
|
|
|
|
|
31
|
alias($class, @_); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |