6 CPAN
::HandleConfig
->load;
7 CPAN
::Shell
::setup_output
;
14 # XXX: stupid CPAN.pm functions die for some modules...
16 $_ => scalar eval { $mod->$_ }
17 } qw(id cpan_version inst_version fullname cpan_file)};
20 # Only list the "root" module of each package, meaning either (1) the
21 # module matching the dist name or (2) the module with the shortest
22 # name, whichever comes first.
29 my $cf = $_->{cpan_file
};
30 if (!exists $h{$cf}) {
31 $h{$_->{cpan_file
}} = $_;
33 (my $tmp = $cf) =~ s/-/::/g;
34 if ($tmp =~ /^\Q$h{$cf}{id}\E/) {
35 next; # already perfect
36 } elsif ($tmp =~ /^\Q$_->{id}\E/) {
37 $h{$cf} = $_; # perfect
38 } # elsif (length $h{$cf}{id} > length $_->{id}) {
39 # $h{$cf} = $_; # short, at least...
43 sort { $a->{id
} cmp $b->{id
} } values %h;
48 CPAN
::Shell
->expand('Module', shift || '/./');
53 group_by_dist
map { interesting_parts
$_ } _list
@_
60 # XXX: key to test in this order, because inst_file is slow.
62 } CPAN
::Shell
->expand('Module', '/./')
67 group_by_dist
map { interesting_parts
$_ } _ls
@_
75 ($_->description =~ /$pat/ || $_->id =~ /$pat/)
76 } CPAN
::Shell
->expand('Module', '/./');
81 group_by_dist
map { interesting_parts
$_ } _desc
@_;
86 grep !$_->uptodate, list
@_;
89 ## stolen from CPAN::Shell...
92 my $dist = CPAN
::Shell
->expand('Module', shift);
95 $dist = $dist->cpan_file;
96 # my ($dist) = $self->id;
97 my ($sans, $suffix) = $dist =~ /(.+)\.(tgz|tar[\._-]gz|tar\.Z|zip)$/;
99 my ($local_wanted) = File
::Spec
->catfile(
100 $CPAN::Config
->{keep_source_where
}, "authors", "id",
101 split(/\//,"$sans.readme"));
102 $local_file = CPAN
::FTP
->localize("authors/id/$sans.readme", $local_wanted);
103 ## Return filename rather than contents to avoid Elisp reader issues...
108 open IN
, $local_wanted;
117 eval q{ use LWP::Simple; };
119 print STDERR
"Can't get perldocs: LWP::Simple not installed.\n";
120 "Can't get perldocs: LWP::Simple not installed.\n";
122 *perldoc
= sub { get
($CPAN::Defaultdocs
. shift) };
129 my $dist = CPAN
::Shell
->expand('Module', shift);
130 $dist->install if $dist;
133 # Based on CPAN::Shell::_u_r_common
136 my $pat = shift || '/./';
137 my (@result, %seen, %need);
138 $version_undefs = $version_zeroes = 0;
139 for my $module (CPAN
::Shell
->expand('Module',$pat)) {
140 my $file = $module->cpan_file;
141 next unless defined $file && $module->inst_file;
143 my $latest = $module->cpan_version;
144 my $have = $module->inst_version;
146 next unless CPAN
::Version
->vgt($latest, $have);
147 push @result, $module;
148 next if $seen{$file}++;
149 $need{$module->id}++;
156 group_by_dist
map { interesting_parts
$_ } _recommend
@_;