line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Nearest; |
2
|
1
|
|
|
1
|
|
12668
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
4
|
|
|
|
|
|
|
require Exporter; |
5
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw/search/; |
7
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
8
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
58
|
|
9
|
1
|
|
|
1
|
|
409
|
use Text::Fuzzy '0.25'; |
|
1
|
|
|
|
|
1035
|
|
|
1
|
|
|
|
|
90
|
|
10
|
1
|
|
|
1
|
|
373
|
use Gzip::Faster '0.18', ':all'; |
|
1
|
|
|
|
|
794
|
|
|
1
|
|
|
|
|
307
|
|
11
|
|
|
|
|
|
|
#use XSLoader; |
12
|
|
|
|
|
|
|
#XSLoader::load 'CPAN::Nearest', $VERSION; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub search |
15
|
|
|
|
|
|
|
{ |
16
|
2
|
|
|
2
|
1
|
12347
|
my ($file, $module) = @_; |
17
|
2
|
50
|
|
|
|
42
|
if (! -f $file) { |
18
|
0
|
|
|
|
|
0
|
carp "Cannot find module file '$file'.\n"; |
19
|
|
|
|
|
|
|
} |
20
|
2
|
|
|
|
|
4
|
my $text; |
21
|
2
|
50
|
|
|
|
10
|
if ($file =~ /\.gz$/) { |
22
|
2
|
|
|
|
|
9
|
$text = gunzip_file ($file); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
|
|
|
|
|
|
# Slurp file |
26
|
0
|
|
|
|
|
0
|
local $/ = undef; |
27
|
0
|
0
|
|
|
|
0
|
open my $in, "<", $file or croak "Error opening '$file': $!"; |
28
|
0
|
|
|
|
|
0
|
$text = <$in>; |
29
|
0
|
0
|
|
|
|
0
|
close $in or die $!; |
30
|
|
|
|
|
|
|
} |
31
|
2
|
|
|
|
|
176281
|
my @modules; |
32
|
|
|
|
|
|
|
# Skip to first line. |
33
|
2
|
|
|
|
|
13235
|
$text =~ s/.*^\s*$//m; |
34
|
2
|
|
|
|
|
282
|
while ($text =~ /^(\S+)\s+(\S+)\s+(\S*)\s*$/gm) { |
35
|
|
|
|
|
|
|
# print "$1\n"; |
36
|
375980
|
|
|
|
|
945223
|
push @modules, $1; |
37
|
|
|
|
|
|
|
} |
38
|
2
|
|
|
|
|
42
|
my $tf = Text::Fuzzy->new ($module, max => 10); |
39
|
2
|
|
|
|
|
13
|
return $tf->nearestv (\@modules); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|