line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Nearest; |
2
|
1
|
|
|
1
|
|
69804
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
4
|
|
|
|
|
|
|
require Exporter; |
5
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw/search/; |
7
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
8
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
9
|
1
|
|
|
1
|
|
496
|
use Text::Fuzzy '0.25'; |
|
1
|
|
|
|
|
1303
|
|
|
1
|
|
|
|
|
121
|
|
10
|
1
|
|
|
1
|
|
477
|
use Gzip::Faster '0.18', 'gunzip_file'; |
|
1
|
|
|
|
|
1333
|
|
|
1
|
|
|
|
|
365
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub search |
13
|
|
|
|
|
|
|
{ |
14
|
2
|
|
|
2
|
1
|
19276
|
my ($file, $module) = @_; |
15
|
2
|
50
|
|
|
|
73
|
if (! -f $file) { |
16
|
0
|
|
|
|
|
0
|
carp "Cannot find module file '$file'.\n"; |
17
|
|
|
|
|
|
|
} |
18
|
2
|
|
|
|
|
5
|
my $text; |
19
|
2
|
50
|
|
|
|
20
|
if ($file =~ /\.gz$/) { |
20
|
2
|
|
|
|
|
10
|
$text = gunzip_file ($file); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
else { |
23
|
|
|
|
|
|
|
# Slurp file |
24
|
0
|
|
|
|
|
0
|
local $/ = undef; |
25
|
0
|
0
|
|
|
|
0
|
open my $in, "<", $file or croak "Error opening '$file': $!"; |
26
|
0
|
|
|
|
|
0
|
$text = <$in>; |
27
|
0
|
0
|
|
|
|
0
|
close $in or die $!; |
28
|
|
|
|
|
|
|
} |
29
|
2
|
|
|
|
|
299998
|
my @modules; |
30
|
|
|
|
|
|
|
# Skip to first line. |
31
|
2
|
|
|
|
|
43282
|
$text =~ s/.*^\s*$//m; |
32
|
2
|
|
|
|
|
1877
|
while ($text =~ /^(\S+)\s+(\S+)\s+(\S*)\s*$/gm) { |
33
|
438790
|
|
|
|
|
1679998
|
push @modules, $1; |
34
|
|
|
|
|
|
|
} |
35
|
2
|
|
|
|
|
50
|
my $tf = Text::Fuzzy->new ($module, max => 10); |
36
|
2
|
|
|
|
|
24
|
return $tf->nearestv (\@modules); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|