line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::AutoINC;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24234
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
4
|
|
|
|
|
|
|
our $PPM;
|
5
|
1
|
|
|
1
|
|
43
|
BEGIN {eval 'use PPM::UI'; $PPM = not "$@"} # Do we have Perl Package Manager?
|
|
1
|
|
|
1
|
|
20
|
|
|
1
|
|
|
|
|
333
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6
|
1
|
|
|
1
|
|
4899
|
use CPAN;
|
|
1
|
|
|
|
|
474487
|
|
|
1
|
|
|
|
|
457
|
|
7
|
1
|
|
|
1
|
|
25
|
use File::Spec;
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
33
|
|
8
|
1
|
|
|
1
|
|
11
|
use File::Basename;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
117
|
|
9
|
1
|
|
|
1
|
|
9
|
use Config;
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
1001
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02';
|
12
|
|
|
|
|
|
|
our $FORCE;
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import {
|
15
|
1
|
|
|
1
|
|
18
|
my $package = shift;
|
16
|
1
|
|
|
|
|
2
|
$FORCE = grep /^force$/i, @_;
|
17
|
1
|
|
|
|
|
3
|
my $ppm = grep /^ppm$/i, @_;
|
18
|
1
|
|
|
|
|
5
|
my $cpan = grep /^cpan$/i, @_;
|
19
|
1
|
50
|
33
|
|
|
12
|
die "You can't specify both PPM and CPAN installation methods."
|
20
|
|
|
|
|
|
|
if $ppm && $cpan;
|
21
|
1
|
50
|
|
|
|
7
|
*Module::AutoINC::INC = *Module::AutoINC::PPMINC if $ppm;
|
22
|
1
|
50
|
|
|
|
24
|
*Module::AutoINC::INC = *Module::AutoINC::CPANINC if $cpan;
|
23
|
|
|
|
|
|
|
}
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
33
|
1
|
0
|
46
|
sub new { bless {}, ref($_[0]) || $_[0] }
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
{
|
28
|
|
|
|
|
|
|
my $ppmpath;
|
29
|
|
|
|
|
|
|
sub Module::AutoINC::PPMINC {
|
30
|
0
|
|
|
0
|
0
|
0
|
my ($self, $filename) = @_;
|
31
|
|
|
|
|
|
|
|
32
|
0
|
|
0
|
|
|
0
|
$ppmpath ||= File::Spec->catfile(dirname($Config{perlpath}), 'ppm');
|
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
0
|
if ($filename =~ /^(.+)\.pm$/) {
|
35
|
0
|
|
|
|
|
0
|
my $module = $1;
|
36
|
0
|
|
|
|
|
0
|
$module =~ tr|/|-|;
|
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
0
|
system($ppmpath, 'install', $FORCE ? '-force' : (), $module);
|
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
foreach my $prefix (@INC) {
|
41
|
0
|
|
|
|
|
0
|
my $realfilename = File::Spec->catfile($prefix,$filename);
|
42
|
0
|
|
|
|
|
0
|
my $fh;
|
43
|
0
|
0
|
0
|
|
|
0
|
return $fh if -f $realfilename && open($fh, $realfilename);
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
return undef;
|
48
|
|
|
|
|
|
|
}
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub Module::AutoINC::CPANINC {
|
52
|
2
|
|
|
2
|
0
|
5686
|
my ($self, $filename) = @_;
|
53
|
|
|
|
|
|
|
|
54
|
2
|
50
|
|
|
|
20
|
if ($filename =~ /^(.+)\.pm$/) {
|
55
|
2
|
|
|
|
|
6
|
my $module = $1;
|
56
|
2
|
|
|
|
|
9
|
$module =~ s|/|::|g;
|
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
24
|
foreach my $m (expand('Module', $module)) {
|
59
|
1
|
50
|
|
|
|
2609815
|
$FORCE ? CPAN::Shell->force('install', $m)
|
60
|
|
|
|
|
|
|
: CPAN::Shell->install($m);
|
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
764
|
foreach my $prefix (@INC) {
|
63
|
12
|
|
|
|
|
109
|
my $realfilename = File::Spec->catfile($prefix,$filename);
|
64
|
12
|
|
|
|
|
19
|
my $fh;
|
65
|
12
|
50
|
33
|
|
|
319
|
return $fh if -f $realfilename && open($fh, $realfilename);
|
66
|
|
|
|
|
|
|
}
|
67
|
|
|
|
|
|
|
}
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
135
|
return undef;
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
BEGIN {
|
75
|
1
|
50
|
|
1
|
|
9
|
*Module::AutoINC::INC = $PPM ? *Module::AutoINC::PPMINC
|
76
|
|
|
|
|
|
|
: *Module::AutoINC::CPANINC;
|
77
|
1
|
|
|
|
|
12
|
push (@INC, new Module::AutoINC());
|
78
|
|
|
|
|
|
|
};
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1;
|
81
|
|
|
|
|
|
|
__END__
|