line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::02Packages::Search; |
2
|
1
|
|
|
1
|
|
71889
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
502
|
use Search::Dict (); |
|
1
|
|
|
|
|
1149
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
518
|
use Symbol (); |
|
1
|
|
|
|
|
815
|
|
|
1
|
|
|
|
|
70
|
|
7
|
1
|
|
|
1
|
|
469
|
use Tie::Handle::SkipHeader; |
|
1
|
|
|
|
|
4114
|
|
|
1
|
|
|
|
|
436
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.100'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
0
|
|
my ($class, %argv) = @_; |
13
|
0
|
|
|
|
|
|
my $fh = $argv{fh}; |
14
|
0
|
0
|
|
|
|
|
if (!$fh) { |
15
|
0
|
|
|
|
|
|
my $file = $argv{file}; |
16
|
0
|
0
|
|
|
|
|
my $skip_header = exists $argv{skip_header} ? $argv{skip_header} : 1; |
17
|
0
|
|
|
|
|
|
$fh = $class->_open($file, $skip_header); |
18
|
|
|
|
|
|
|
} |
19
|
0
|
|
|
|
|
|
bless { fh => $fh }, $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _open { |
23
|
0
|
|
|
0
|
|
|
my ($class, $file, $skip_header) = @_; |
24
|
0
|
0
|
|
|
|
|
if ($skip_header) { |
25
|
0
|
|
|
|
|
|
my $fh = Symbol::gensym; |
26
|
0
|
0
|
|
|
|
|
tie *$fh, 'Tie::Handle::SkipHeader', '<', $file or die "$!: $file\n"; |
27
|
0
|
|
|
|
|
|
return $fh; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
0
|
|
|
|
|
open my $fh, "<", $file or die "$!: $file\n"; |
30
|
0
|
|
|
|
|
|
$fh; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub search { |
34
|
0
|
|
|
0
|
0
|
|
my ($self, $package) = @_; |
35
|
0
|
|
|
|
|
|
my $fh = $self->{fh}; |
36
|
0
|
|
|
|
|
|
seek $fh, 0, 0; |
37
|
0
|
|
|
|
|
|
my $pos = Search::Dict::look $fh, $package, { xfrm => \&_xform_package, fold => 1 }; |
38
|
0
|
0
|
0
|
|
|
|
return if $pos == -1 || eof $fh; |
39
|
0
|
|
|
|
|
|
while (my $line = <$fh>) { |
40
|
0
|
0
|
|
|
|
|
last if $line !~ /\A\Q$package\E\s+/i; |
41
|
0
|
|
|
|
|
|
chomp $line; |
42
|
0
|
|
|
|
|
|
my ($_package, $version, $path) = split /\s+/, $line, 4; |
43
|
0
|
0
|
|
|
|
|
if ($package eq $_package) { |
44
|
0
|
0
|
|
|
|
|
$version = undef if $version eq 'undef'; |
45
|
0
|
|
|
|
|
|
return { version => $version, path => $path }; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
0
|
|
|
sub _xform_package { (split " ", $_[0], 2)[0] } |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |