| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Acme::TLDR; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Abbreviate Perl namespaces for the Extreme Perl Golf |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
47513
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
71
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use utf8; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
12
|
|
|
7
|
2
|
|
|
2
|
|
56
|
use warnings qw(all); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
80
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
8
|
use Digest::MD5 qw(md5_hex); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
152
|
|
|
10
|
2
|
|
|
2
|
|
1750
|
use ExtUtils::Installed; |
|
|
2
|
|
|
|
|
231325
|
|
|
|
2
|
|
|
|
|
71
|
|
|
11
|
2
|
|
|
2
|
|
2975
|
use File::HomeDir; |
|
|
2
|
|
|
|
|
13711
|
|
|
|
2
|
|
|
|
|
142
|
|
|
12
|
2
|
|
|
2
|
|
1901
|
use File::Spec::Functions; |
|
|
2
|
|
|
|
|
1827
|
|
|
|
2
|
|
|
|
|
171
|
|
|
13
|
2
|
|
|
2
|
|
3223
|
use Filter::Simple; |
|
|
2
|
|
|
|
|
74131
|
|
|
|
2
|
|
|
|
|
15
|
|
|
14
|
2
|
|
|
2
|
|
2344
|
use List::MoreUtils qw(uniq); |
|
|
2
|
|
|
|
|
2607
|
|
|
|
2
|
|
|
|
|
160
|
|
|
15
|
2
|
|
|
2
|
|
7008
|
use Module::CoreList; |
|
|
2
|
|
|
|
|
113779
|
|
|
|
2
|
|
|
|
|
26
|
|
|
16
|
2
|
|
|
2
|
|
5999
|
use Storable; |
|
|
2
|
|
|
|
|
7900
|
|
|
|
2
|
|
|
|
|
1084
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.004'; # VERSION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# hack; only absolute paths |
|
22
|
2
|
|
|
2
|
|
8
|
BEGIN { @main::INC = grep { substr($_, 0, 1) eq substr($^X, 0, 1) } @INC } |
|
|
22
|
|
|
|
|
1645
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
FILTER_ONLY |
|
25
|
|
|
|
|
|
|
code => sub { |
|
26
|
|
|
|
|
|
|
my $installed = _installed(); |
|
27
|
|
|
|
|
|
|
my $shortened = _shorten($installed); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
while (my ($long, $short) = each %{$shortened}) { |
|
30
|
|
|
|
|
|
|
s{\b\Q$short\E\b}{$long}gsx; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
}; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _debug { |
|
35
|
1210
|
|
|
1210
|
|
2065
|
my ($fmt, @args) = @_; |
|
36
|
1210
|
100
|
|
|
|
7164
|
printf STDERR qq($fmt\n) => @args |
|
37
|
|
|
|
|
|
|
if exists $ENV{DEBUG}; |
|
38
|
1210
|
|
|
|
|
3427
|
return; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _installed { |
|
42
|
2
|
|
|
2
|
|
29
|
my $cache = catfile( |
|
43
|
|
|
|
|
|
|
File::HomeDir->my_data, |
|
44
|
|
|
|
|
|
|
q(.Acme-TLDR-) . md5_hex(join ':' => sort @INC) . q(.cache) |
|
45
|
|
|
|
|
|
|
); |
|
46
|
2
|
|
|
|
|
5056
|
_debug(q(ExtUtils::Installed cache: %s), $cache); |
|
47
|
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
222
|
my $updated = -M $cache; |
|
49
|
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
6
|
my $modules; |
|
51
|
2
|
50
|
33
|
|
|
18
|
if ( |
|
52
|
0
|
0
|
|
|
|
0
|
not defined $updated |
|
53
|
|
|
|
|
|
|
or |
|
54
|
0
|
|
|
|
|
0
|
grep { -e and -M _ < $updated } |
|
55
|
|
|
|
|
|
|
map { catfile($_, q(perllocal.pod)) } |
|
56
|
|
|
|
|
|
|
@INC |
|
57
|
|
|
|
|
|
|
) { |
|
58
|
|
|
|
|
|
|
## no critic (ProhibitPackageVars) |
|
59
|
2
|
|
|
|
|
8
|
_debug(q(no cache found; generating)); |
|
60
|
2
|
|
|
|
|
23
|
$modules = [ |
|
61
|
|
|
|
|
|
|
uniq |
|
62
|
2
|
|
|
|
|
4
|
keys %{$Module::CoreList::version{$]}}, |
|
63
|
|
|
|
|
|
|
ExtUtils::Installed->new->modules, |
|
64
|
|
|
|
|
|
|
]; |
|
65
|
2
|
50
|
|
|
|
1374003
|
store $modules => $cache |
|
66
|
|
|
|
|
|
|
unless exists $ENV{NOCACHE}; |
|
67
|
|
|
|
|
|
|
} else { |
|
68
|
0
|
|
|
|
|
0
|
_debug(q(reading from cache)); |
|
69
|
0
|
|
|
|
|
0
|
$modules = retrieve $cache; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
15
|
return $modules; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _shorten { |
|
76
|
2
|
|
|
2
|
|
5
|
my ($modules) = @_; |
|
77
|
2
|
|
|
|
|
3
|
my %collisions = map { $_ => 1 } @{$modules}; |
|
|
1430
|
|
|
|
|
2801
|
|
|
|
2
|
|
|
|
|
12
|
|
|
78
|
2
|
|
|
|
|
83
|
my %modules; |
|
79
|
|
|
|
|
|
|
|
|
80
|
2
|
|
|
|
|
4
|
for my $long (sort @{$modules}) { |
|
|
2
|
|
|
|
|
733
|
|
|
81
|
1430
|
|
|
|
|
11000
|
my @parts = split /\b|(?=[A-Z0-9])/x, $long; |
|
82
|
1430
|
100
|
|
|
|
3156
|
next unless $#parts; |
|
83
|
|
|
|
|
|
|
|
|
84
|
1280
|
100
|
|
|
|
1689
|
my $short = join q() => map { /^(\w)\w{3,}$/x ? $1 : $_ } @parts; |
|
|
7196
|
|
|
|
|
16701
|
|
|
85
|
1280
|
100
|
|
|
|
3066
|
next if $short eq $long; |
|
86
|
|
|
|
|
|
|
|
|
87
|
1206
|
100
|
|
|
|
2197
|
unless (exists $collisions{$short}) { |
|
88
|
1098
|
|
|
|
|
2261
|
++$collisions{$short}; |
|
89
|
1098
|
|
|
|
|
2393
|
$modules{$long} = $short; |
|
90
|
1098
|
|
|
|
|
1812
|
_debug(q(%-64s => %s), $long, $short); |
|
91
|
|
|
|
|
|
|
} else { |
|
92
|
108
|
|
|
|
|
191
|
_debug(q(%-64s => *undef*), $long); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
2
|
|
|
|
|
716
|
return \%modules; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |