line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package abbreviation; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
11674
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
47
|
|
4
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
189
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub import { |
8
|
1
|
|
|
1
|
|
11
|
my($class, @pkg) = @_; |
9
|
1
|
50
|
|
|
|
5
|
return unless @pkg; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
3
|
for my $pkg (@pkg) { |
12
|
4
|
|
|
|
|
260
|
eval qq(require $pkg); |
13
|
4
|
50
|
33
|
|
|
24
|
die if $@ && $@ !~ /^Can't locate .*? at \(eval /; #'; |
14
|
4
|
100
|
|
|
|
10
|
my $abbr = _abbr($pkg) or next; |
15
|
1
|
|
|
1
|
|
8
|
no strict 'refs'; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
265
|
|
16
|
3
|
|
|
|
|
5
|
*{$abbr . '::'} = *{$pkg . '::'}; |
|
3
|
|
|
|
|
2133
|
|
|
3
|
|
|
|
|
15
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _abbr { |
21
|
4
|
|
|
4
|
|
7
|
my $pkg = shift; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Top level => nothing |
24
|
4
|
100
|
|
|
|
20
|
return unless $pkg =~ /::/; |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
13
|
my @pkg = split /::/, $pkg; |
27
|
3
|
|
|
|
|
6
|
my $lastone = pop @pkg; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Mission: |
30
|
|
|
|
|
|
|
# Foo::Bar::Baz -> F::B::Baz |
31
|
|
|
|
|
|
|
# Foo::bar::Baz -> F::b::Baz |
32
|
|
|
|
|
|
|
# FooBar::Bar::Baz -> FB::B::Baz |
33
|
|
|
|
|
|
|
# FOO::Bar -> F::Bar |
34
|
4
|
|
|
|
|
15
|
return join '::', (map { |
35
|
3
|
|
|
|
|
5
|
s/^([A-Z])[A-Z0-9]+$/$1/; # FOO -> F |
36
|
4
|
|
|
|
|
9
|
tr/A-Z0-9//cd; |
37
|
4
|
|
|
|
|
20
|
$_; |
38
|
|
|
|
|
|
|
} @pkg), $lastone; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |