File Coverage

blib/lib/Acme/Intraweb.pm
Criterion Covered Total %
statement 20 25 80.0
branch 3 10 30.0
condition 0 3 0.0
subroutine 6 6 100.0
pod n/a
total 29 44 65.9


line stmt bran cond sub pod time code
1             package Acme::Intraweb;
2              
3             =begin comment
4              
5             28600 lines in CPANPLUS. Hard-coded to /usr/home/root - doesn't read user's conf
6             ig file and a config file or parameters from it can't be specified. Have to edit
7             /usr/lib/perl5/site_perl/$perlversion/CPANPLUS/Config.pm.
8             Might be able to get CPANPLUS working with the PERL5_CPANPLUS_CONFIG environment variable.
9             Though a 'use lib "/home/person/.cpanplus/"' would make us use the correct per-use
10             config file...
11              
12             XXX should let the user will do something like 'use lib' in their code and place
13             modules there - use a PREFIX of the first thing in @INC. Otherwise superuser
14             Perl installs will fail. Only when perl is installed by a user/group as is
15             running the Perl programs will this work.
16              
17             =cut
18              
19              
20             $VERSION = 1.02;
21              
22 1     1   16554 use strict;
  1         2  
  1         40  
23 1     1   5 use warnings;
  1         2  
  1         33  
24              
25 1     1   2953 use CPAN;
  1         353108  
  1         524  
26 1     1   26 use File::Spec;
  1         5  
  1         403  
27              
28             my $loaded; # we try to add ourselves to @INC only once and that's on first use
29             my $tried; # no second tries on installing a module
30              
31             sub import {
32             $loaded++ or push @INC, sub {
33              
34 6     6   39619729 my $fn = my $mod = $_[1];
35 6         43 for($mod) { s./.::.g; s/.pm$//i; }
  6         35  
  6         91  
36              
37 6 100       62 if ( not $tried->{$mod}++ ) {
38              
39             # system qq{cpanp i "$mod"};
40             # could dup and then close STDOUT and STDERR for silent option
41 3         78 CPAN::Shell->install($mod);
42              
43 0         0 for(@INC) {
44 0 0       0 next if ref;
45 0 0 0     0 if(-e "$_/$fn" and -r _) {
46 0 0       0 open my $fh, "$_/$fn" or die $!;
47 0         0 return $fh;
48             }
49             }
50             }
51              
52 3         138 return undef;
53              
54             }
55 1 50   1   3411 }
56             1;
57              
58             __END__