line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::InstalledVersion; |
2
|
|
|
|
|
|
|
$Module::InstalledVersion::VERSION = '0.05_01'; |
3
|
1
|
|
|
1
|
|
31
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
54
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
8
|
1
|
|
|
1
|
|
5
|
use File::Spec (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
640
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=pod |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Module::InstalledVersion - Find out what version of a module is installed |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Module::InstalledVersion; |
21
|
|
|
|
|
|
|
my $m = new Module::InstalledVersion 'Foo::Bar'; |
22
|
|
|
|
|
|
|
print "Version is $m->{version}\n"; |
23
|
|
|
|
|
|
|
print "Directory is $m->{dir}\n"; |
24
|
|
|
|
|
|
|
print "Path is $m->{path}\n"; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
This module finds out what version of another module is installed, |
29
|
|
|
|
|
|
|
without running that module. It uses the same regexp technique used by |
30
|
|
|
|
|
|
|
L for figuring this out. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Note that it won't work if the module you're looking at doesn't set |
33
|
|
|
|
|
|
|
$VERSION properly. This is true of far too many CPAN modules. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
39
|
sub new { |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
1188
|
|
|
1
|
|
|
|
|
40
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
38
|
3
|
|
|
3
|
0
|
11
|
shift; |
39
|
1
|
|
|
|
|
400
|
my ($module_name) = @_; |
|
3
|
|
|
|
|
9
|
|
40
|
3
|
50
|
|
|
|
982
|
my $self = {}; |
|
3
|
|
|
|
|
13
|
|
41
|
3
|
|
|
|
|
453275
|
$module_name = File::Spec->catfile(split(/::/, $module_name)); |
|
3
|
|
|
|
|
71
|
|
42
|
3
|
|
|
|
|
36
|
|
43
|
3
|
|
|
|
|
1980
|
DIR: foreach my $dir (@INC) { |
|
3
|
|
|
|
|
22
|
|
|
3
|
|
|
|
|
14
|
|
44
|
29
|
|
|
|
|
513
|
my $filename = File::Spec->catfile($dir, "$module_name.pm"); |
45
|
29
|
100
|
|
|
|
762
|
if (-e $filename ) { |
46
|
0
|
|
|
|
|
0
|
$self->{dir} = $dir; |
|
3
|
|
|
|
|
15
|
|
47
|
3
|
|
|
|
|
12
|
$self->{path} = $filename; |
48
|
3
|
50
|
|
|
|
217
|
if (open IN, "$filename") { |
49
|
3
|
|
|
|
|
54
|
while () { |
50
|
|
|
|
|
|
|
# the following regexp comes from the Extutils::MakeMaker |
51
|
|
|
|
|
|
|
# documentation. |
52
|
79
|
100
|
|
6
|
|
241
|
if (/([\$*])(([\w\:\']*)\bVERSION)\b.*\=/) { |
|
6
|
|
|
|
|
10
|
|
53
|
3
|
|
|
|
|
8
|
local $VERSION; |
54
|
3
|
|
|
|
|
390
|
my $res = eval $_; |
|
6
|
|
|
|
|
30
|
|
55
|
3
|
|
66
|
|
|
31
|
$self->{version} = $VERSION || $res; |
56
|
3
|
|
|
|
|
13
|
last DIR; |
|
6
|
|
|
|
|
22
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} else { |
60
|
0
|
|
|
|
|
0
|
Carp::carp "Can't open $filename: $!"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
3
|
|
|
|
|
4
|
bless $self; |
65
|
3
|
|
|
|
|
9
|
return $self; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SEE ALSO |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L, |
73
|
|
|
|
|
|
|
L, |
74
|
|
|
|
|
|
|
L, |
75
|
|
|
|
|
|
|
L, |
76
|
|
|
|
|
|
|
L, |
77
|
|
|
|
|
|
|
L, |
78
|
|
|
|
|
|
|
L, |
79
|
|
|
|
|
|
|
L. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 REPOSITORY |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Copyright (c) 2001 Kirrily Robert. |
88
|
|
|
|
|
|
|
This program is free software; you may redistribute it |
89
|
|
|
|
|
|
|
and/or modify it under the same terms as Perl itself. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Kirrily "Skud" Robert |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |