In Perl_apply, the name of the op can be found from PL_op_name, instead
[p5sagit/p5-mst-13.2.git] / lib / CPAN.pm
index 558d93b..6c79d6f 100644 (file)
@@ -1,12 +1,9 @@
 # -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*-
 package CPAN;
-$VERSION = '1.71';
-# $Id: CPAN.pm,v 1.405 2003/07/04 08:06:11 k Exp $
-
-# only used during development:
-$Revision = "";
-# $Revision = "[".substr(q$Revision: 1.405 $, 10)."]";
+$VERSION = '1.80';
+$VERSION = eval $VERSION;
 
+use CPAN::Version;
 use Carp ();
 use Config ();
 use Cwd ();
@@ -17,12 +14,13 @@ use File::Basename ();
 use File::Copy ();
 use File::Find;
 use File::Path ();
+use File::Spec;
+use File::Temp ();
 use FileHandle ();
 use Safe ();
+use Sys::Hostname;
 use Text::ParseWords ();
 use Text::Wrap;
-use File::Spec;
-use Sys::Hostname;
 no lib "."; # we need to run chdir all over and we would get at wrong
             # libraries there
 
@@ -53,19 +51,25 @@ $CPAN::DEBUG ||= 0;
 $CPAN::Signal ||= 0;
 $CPAN::Frontend ||= "CPAN::Shell";
 $CPAN::Defaultsite ||= "ftp://ftp.perl.org/pub/CPAN";
+$CPAN::Perl ||= CPAN::find_perl();
+$CPAN::Defaultdocs ||= "http://search.cpan.org/perldoc?";
+$CPAN::Defaultrecent ||= "http://search.cpan.org/recent";
+
 
 package CPAN;
-use strict qw(vars);
+use strict;
 
 use vars qw($VERSION @EXPORT $AUTOLOAD $DEBUG $META $HAS_USABLE $term
-            $Revision $Signal $End $Suppress_readline $Frontend
-            $Defaultsite $Have_warned);
+            $Signal $End $Suppress_readline $Frontend
+            $Defaultsite $Have_warned $Defaultdocs $Defaultrecent
+            $Be_Silent );
 
 @CPAN::ISA = qw(CPAN::Debug Exporter);
 
 @EXPORT = qw(
-            autobundle bundle expand force get cvs_import
+            autobundle bundle expand force notest get cvs_import
             install make readme recompile shell test clean
+             perldoc recent
            );
 
 #-> sub CPAN::AUTOLOAD ;
@@ -78,12 +82,13 @@ sub AUTOLOAD {
     if (exists $EXPORT{$l}){
        CPAN::Shell->$l(@_);
     } else {
-       $CPAN::Frontend->mywarn(qq{Unknown command "$AUTOLOAD". }.
+       $CPAN::Frontend->mywarn(qq{Unknown CPAN command "$AUTOLOAD". }.
                                qq{Type ? for help.
 });
     }
 }
 
+
 #-> sub CPAN::shell ;
 sub shell {
     my($self) = @_;
@@ -145,12 +150,11 @@ sub shell {
 
     $CPAN::Frontend->myprint(
                             sprintf qq{
-cpan shell -- CPAN exploration and modules installation (v%s%s)
+cpan shell -- CPAN exploration and modules installation (v%s)
 ReadLine support %s
 
 },
                              $CPAN::VERSION,
-                             $CPAN::Revision,
                              $rl_avail
                             )
         unless $CPAN::Config->{'inhibit_startup_message'} ;
@@ -234,7 +238,7 @@ package CPAN::CacheMgr;
 use File::Find;
 
 package CPAN::Config;
-use vars qw(%can $dot_cpan);
+use vars qw(%can %keys $dot_cpan);
 
 %can = (
   'commit' => "Commit changes to disk",
@@ -242,20 +246,39 @@ use vars qw(%can $dot_cpan);
   'init'   => "Interactive setting of all options",
 );
 
+%keys = map { $_ => undef } qw(
+    build_cache build_dir
+    cache_metadata cpan_home curl
+    dontload_hash
+    ftp ftp_proxy
+    getcwd gpg gzip
+    histfile histsize http_proxy
+    inactivity_timeout index_expire inhibit_startup_message
+    keep_source_where
+    lynx
+    make make_arg make_install_arg make_install_make_command makepl_arg
+    ncftp ncftpget no_proxy pager
+    prerequisites_policy
+    scan_cache shell show_upload_date
+    tar term_is_latin
+    unzip urllist
+    wait_list wget
+);
+
 package CPAN::FTP;
 use vars qw($Ua $Thesite $Themethod);
 @CPAN::FTP::ISA = qw(CPAN::Debug);
 
 package CPAN::LWP::UserAgent;
 use vars qw(@ISA $USER $PASSWD $SETUPDONE);
-# we delay requiring LWP::UserAgent and setting up inheritence until we need it
+# we delay requiring LWP::UserAgent and setting up inheritance until we need it
 
 package CPAN::Complete;
 @CPAN::Complete::ISA = qw(CPAN::Debug);
 @CPAN::Complete::COMMANDS = sort qw(
                       ! a b d h i m o q r u autobundle clean dump
                       make test install force readme reload look
-                       cvs_import ls
+                       cvs_import ls perldoc recent
 ) unless @CPAN::Complete::COMMANDS;
 
 package CPAN::Index;
@@ -327,7 +350,7 @@ For this you just need to type
 });
        }
     } else {
-       $CPAN::Frontend->mywarn(qq{Unknown command '$autoload'. }.
+       $CPAN::Frontend->mywarn(qq{Unknown shell command '$autoload'. }.
                                qq{Type ? for help.
 });
     }
@@ -667,6 +690,32 @@ sub cwd {Cwd::cwd();}
 #-> sub CPAN::getcwd ;
 sub getcwd {Cwd::getcwd();}
 
+#-> sub CPAN::find_perl ;
+sub find_perl {
+    my($perl) = File::Spec->file_name_is_absolute($^X) ? $^X : "";
+    my $pwd  = CPAN::anycwd();
+    my $candidate = File::Spec->catfile($pwd,$^X);
+    $perl ||= $candidate if MM->maybe_command($candidate);
+
+    unless ($perl) {
+       my ($component,$perl_name);
+      DIST_PERLNAME: foreach $perl_name ($^X, 'perl', 'perl5', "perl$]") {
+           PATH_COMPONENT: foreach $component (File::Spec->path(),
+                                               $Config::Config{'binexp'}) {
+                 next unless defined($component) && $component;
+                 my($abs) = File::Spec->catfile($component,$perl_name);
+                 if (MM->maybe_command($abs)) {
+                     $perl = $abs;
+                     last DIST_PERLNAME;
+                 }
+             }
+         }
+    }
+
+    return $perl;
+}
+
+
 #-> sub CPAN::exists ;
 sub exists {
     my($mgr,$class,$id) = @_;
@@ -703,7 +752,7 @@ sub has_usable {
                        sub {require HTTP::Request},
                        sub {require URI::URL},
                       ],
-               Net::FTP => [
+               'Net::FTP' => [
                             sub {require Net::FTP},
                             sub {require Net::Config},
                            ]
@@ -738,7 +787,6 @@ sub has_inst {
     my $file = $mod;
     my $obj;
     $file =~ s|::|/|g;
-    $file =~ s|/|\\|g if $^O eq 'MSWin32';
     $file .= ".pm";
     if ($INC{$file}) {
        # checking %INC is wrong, because $INC{LWP} may be true
@@ -755,7 +803,7 @@ sub has_inst {
 
        $CPAN::Frontend->myprint("CPAN: $mod loaded ok\n");
        if ($mod eq "CPAN::WAIT") {
-           push @CPAN::Shell::ISA, CPAN::WAIT;
+           push @CPAN::Shell::ISA, 'CPAN::WAIT';
        }
        return 1;
     } elsif ($mod eq "Net::FTP") {
@@ -773,6 +821,22 @@ sub has_inst {
 
 });
        sleep 2;
+    } elsif ($mod eq "Module::Signature"){
+       unless ($Have_warned->{"Module::Signature"}++) {
+           # No point in complaining unless the user can
+           # reasonably install and use it.
+           if (eval { require Crypt::OpenPGP; 1 } ||
+               defined $CPAN::Config->{'gpg'}) {
+               $CPAN::Frontend->myprint(qq{
+  CPAN: Module::Signature security checks disabled because Module::Signature
+  not installed.  Please consider installing the Module::Signature module.
+  You may also need to be able to connect over the Internet to the public
+  keyservers like pgp.mit.edu (port 11371).
+
+});
+               sleep 2;
+           }
+       }
     } else {
        delete $INC{$file}; # if it inc'd LWP but failed during, say, URI
     }
@@ -1050,6 +1114,9 @@ sub edit {
        return 1;
     } else {
         CPAN->debug("o[$o]") if $CPAN::DEBUG;
+        unless (exists $keys{$o}) {
+            $CPAN::Frontend->mywarn("Warning: unknown configuration variable '$o'\n");
+        }
        if ($o =~ /list$/) {
            $func = shift @args;
            $func ||= "";
@@ -1096,8 +1163,8 @@ sub prettyprint {
   if (ref $v) {
     my(@report) = ref $v eq "ARRAY" ?
         @$v :
-            map { sprintf("   %-18s => %s\n",
-                          $_,
+            map { sprintf("   %-18s => [%s]\n",
+                          map { "[$_]" } $_,
                           defined $v->{$_} ? $v->{$_} : "UNDEFINED"
                          )} keys %$v;
     $CPAN::Frontend->myprint(
@@ -1107,13 +1174,13 @@ sub prettyprint {
                                           "    %-18s\n",
                                           $k
                                          ),
-                                  map {"\t$_\n"} @report
+                                  map {"\t[$_]\n"} @report
                                  )
                             );
   } elsif (defined $v) {
-    $CPAN::Frontend->myprint(sprintf "    %-18s %s\n", $k, $v);
+    $CPAN::Frontend->myprint(sprintf "    %-18s [%s]\n", $k, $v);
   } else {
-    $CPAN::Frontend->myprint(sprintf "    %-18s %s\n", $k, "UNDEFINED");
+    $CPAN::Frontend->myprint(sprintf "    %-18s [%s]\n", $k, "UNDEFINED");
   }
 }
 
@@ -1201,14 +1268,14 @@ sub _configpmtest {
         #_#_# following code dumped core on me with 5.003_11, a.k.
         my $configpm_bak = "$configpmtest.bak";
         unlink $configpm_bak if -f $configpm_bak;
-        if( -f $configpmtest ) {       
-            if( rename $configpmtest, $configpm_bak ) {  
-                $CPAN::Frontend->mywarn(<<END)
+        if( -f $configpmtest ) {
+            if( rename $configpmtest, $configpm_bak ) {
+                               $CPAN::Frontend->mywarn(<<END);
 Old configuration file $configpmtest
     moved to $configpm_bak
 END
            }
-       }       
+       }
        my $fh = FileHandle->new;
        if ($fh->open(">$configpmtest")) {
            $fh->print("1;\n");
@@ -1217,12 +1284,14 @@ END
            # Should never happen
            Carp::confess("Cannot open >$configpmtest");
        }
-    } else { return } 
+    } else { return }
 }
 
 #-> sub CPAN::Config::load ;
 sub load {
-    my($self) = shift;
+    my($self, %args) = @_;
+       $CPAN::Be_Silent++ if $args{be_silent};
+
     my(@miss);
     use Carp;
     eval {require CPAN::Config;};       # We eval because of some
@@ -1258,8 +1327,9 @@ sub load {
            $configpmtest = File::Spec->catfile($configpmdir,"MyConfig.pm");
            $configpm = _configpmtest($configpmdir,$configpmtest); 
            unless ($configpm) {
-               Carp::confess(qq{WARNING: CPAN.pm is unable to }.
-                             qq{create a configuration file.});
+                       my $text = qq{WARNING: CPAN.pm is unable to } .
+                         qq{create a configuration file.}; 
+                       output($text, 'confess');
            }
        }
     }
@@ -1272,8 +1342,9 @@ END
     $CPAN::Frontend->myprint(qq{
 $configpm initialized.
 });
+
     sleep 2;
-    CPAN::FirstTime::init($configpm);
+    CPAN::FirstTime::init($configpm, %args);
 }
 
 #-> sub CPAN::Config::missing_config_data ;
@@ -1341,7 +1412,11 @@ sub cpl {
     } elsif (@words >= 4) {
        return ();
     }
-    my(@o_conf) = (keys %CPAN::Config::can, keys %$CPAN::Config);
+    my %seen;
+    my(@o_conf) =  sort grep { !$seen{$_}++ }
+        keys %CPAN::Config::can,
+            keys %$CPAN::Config,
+                keys %CPAN::Config::keys;
     return grep /^\Q$word\E/, @o_conf;
 }
 
@@ -1357,24 +1432,27 @@ sub h {
 Display Information
  command  argument          description
  a,b,d,m  WORD or /REGEXP/  about authors, bundles, distributions, modules
- i        WORD or /REGEXP/  about anything of above
- r        NONE              reinstall recommendations
+ i        WORD or /REGEXP/  about any of the above
+ r        NONE              report updatable modules
  ls       AUTHOR            about files in the author's directory
+    (with WORD being a module, bundle or author name or a distribution
+    name of the form AUTHOR/DISTRIBUTION)
 
 Download, Test, Make, Install...
- get                        download
- make                       make (implies get)
- test      MODULES,         make test (implies make)
- install   DISTS, BUNDLES   make install (implies test)
- clean                      make clean
- look                       open subshell in these dists' directories
- readme                     display these dists' README files
+ get      download                     clean    make clean
+ make     make (implies get)           look     open subshell in dist directory
+ test     make test (implies make)     readme   display these README files
+ install  make install (implies test)  perldoc  display POD documentation
+
+Pragmas
+ force COMMAND    unconditionally do command
+ notest COMMAND   skip testing
 
 Other
  h,?           display this menu       ! perl-code   eval a perl command
  o conf [opt]  set and query options   q             quit the cpan shell
  reload cpan   load CPAN.pm again      reload index  load newer indices
- autobundle    Snapshot                force cmd     unconditionally do cmd});
+ autobundle    Snapshot                recent        latest CPAN uploads});
     }
 }
 
@@ -1391,19 +1469,35 @@ sub a {
 }
 
 #-> sub CPAN::Shell::ls ;
-sub ls      {
+sub ls {
     my($self,@arg) = @_;
     my @accept;
+    if ($arg[0] eq "*") {
+        @arg = map { $_->id } $self->expand('Author','/./');
+    }
     for (@arg) {
-        unless (/^[A-Z\-]+$/i) {
+        unless (/^[A-Z0-9\-]+$/i) {
             $CPAN::Frontend->mywarn("ls command rejects argument $_: not an author\n");
             next;
         }
         push @accept, uc $_;
     }
+    my $silent = @accept>1;
+    my $last_alpha = "";
     for my $a (@accept){
         my $author = $self->expand('Author',$a) or die "No author found for $a";
-        $author->ls;
+        $author->ls($silent); # silent if more than one author
+        if ($silent) {
+            my $alphadot = substr $author->id, 0, 1;
+            my $ad;
+            if ($alphadot eq $last_alpha) {
+                $ad = ".";
+            } else {
+                $ad = $alphadot;
+                $last_alpha = $alphadot;
+            }
+            $CPAN::Frontend->myprint($ad);
+        }
     }
 }
 
@@ -1453,13 +1547,14 @@ sub m { # emacs confused here }; sub mimimimimi { # emacs in sync here
 sub i {
     my($self) = shift;
     my(@args) = @_;
-    my(@type,$type,@m);
-    @type = qw/Author Bundle Distribution Module/;
     @args = '/./' unless @args;
     my(@result);
-    for $type (@type) {
+    for my $type (qw/Bundle Distribution Module/) {
        push @result, $self->expand($type,@args);
     }
+    # Authors are always uppercase.
+    push @result, $self->expand("Author", map { uc $_ } @args);
+
     my $result = @result == 1 ?
        $result[0]->as_string :
             @result == 0 ?
@@ -1493,7 +1588,7 @@ sub o {
            $CPAN::Frontend->myprint(":\n");
            for $k (sort keys %CPAN::Config::can) {
                $v = $CPAN::Config::can{$k};
-               $CPAN::Frontend->myprint(sprintf "    %-18s %s\n", $k, $v);
+               $CPAN::Frontend->myprint(sprintf "    %-18s [%s]\n", $k, $v);
            }
            $CPAN::Frontend->myprint("\n");
            for $k (sort keys %$CPAN::Config) {
@@ -1587,12 +1682,18 @@ sub reload {
     if ($command =~ /cpan/i) {
         for my $f (qw(CPAN.pm CPAN/FirstTime.pm)) {
             next unless $INC{$f};
-            CPAN->debug("reloading the whole $f") if $CPAN::DEBUG;
+            my $pwd = CPAN::anycwd();
+            CPAN->debug("reloading the whole '$f' from '$INC{$f}' while pwd='$pwd'")
+                if $CPAN::DEBUG;
             my $fh = FileHandle->new($INC{$f});
             local($/);
             my $redef = 0;
+            local $^W = 1;
             local($SIG{__WARN__}) = paintdots_onreload(\$redef);
-            eval <$fh>;
+            my $eval = <$fh>;
+            CPAN->debug("evaling '$eval'")
+                if $CPAN::DEBUG;
+            eval $eval;
             warn $@ if $@;
             $CPAN::Frontend->myprint("\n$redef subroutines redefined\n");
         }
@@ -1665,14 +1766,9 @@ sub _u_r_common {
              # for metadata cache
         $CPAN::Frontend->myprint(sprintf "%d matches in the database\n", $expand);
     }
-    for $module (@expand) {
+  MODULE: for $module (@expand) {
        my $file  = $module->cpan_file;
-       next unless defined $file; # ??
-        # Don't offer to upgrade the core base.pm with the base.pm of
-        # the Class::Fields.  Don't autobundle the core base.pm, either.
-        # This is a horrible hack but hopefully cases like this are very,
-        # very rare indeed.
-        next if $module->id eq 'base' && $file =~ m{/Class-Fields-};
+       next MODULE unless defined $file; # ??
        my($latest) = $module->cpan_version;
        my($inst_file) = $module->inst_file;
        my($have);
@@ -1688,18 +1784,18 @@ sub _u_r_common {
                } elsif ($have == 0){
                    $version_zeroes++;
                }
-               next unless CPAN::Version->vgt($latest, $have);
+               next MODULE unless CPAN::Version->vgt($latest, $have);
 # to be pedantic we should probably say:
 #    && !($have eq "undef" && $latest ne "undef" && $latest gt "");
 # to catch the case where CPAN has a version 0 and we have a version undef
            } elsif ($what eq "u") {
-               next;
+               next MODULE;
            }
        } else {
            if ($what eq "a") {
-               next;
+               next MODULE;
            } elsif ($what eq "r") {
-               next;
+               next MODULE;
            } elsif ($what eq "u") {
                $have = "-";
            }
@@ -1710,11 +1806,11 @@ sub _u_r_common {
            push @result, sprintf "%s %s\n", $module->id, $have;
        } elsif ($what eq "r") {
            push @result, $module->id;
-           next if $seen{$file}++;
+           next MODULE if $seen{$file}++;
        } elsif ($what eq "u") {
            push @result, $module->id;
-           next if $seen{$file}++;
-           next if $file =~ /^Contact/;
+           next MODULE if $seen{$file}++;
+           next MODULE if $file =~ /^Contact/;
        }
        unless ($headerdone++){
            $CPAN::Frontend->myprint("\n");
@@ -1957,6 +2053,27 @@ sub format_result {
     $result;
 }
 
+#-> sub CPAN::Shell::report_fh ;
+{
+    my $installation_report_fh;
+    my $previously_noticed = 0;
+
+    sub report_fh {
+        return $installation_report_fh if $installation_report_fh;
+        $installation_report_fh = File::Temp->new(
+                                                  template => 'cpan_install_XXXX',
+                                                  suffix   => '.txt',
+                                                  unlink   => 0,
+                                                 );
+        unless ( $installation_report_fh ) {
+            warn("Couldn't open installation report file; " .
+                 "no report file will be generated."
+                ) unless $previously_noticed++;
+        }
+    }
+}
+
+
 # The only reason for this method is currently to have a reliable
 # debugging utility that reveals which output is going through which
 # channel. No, I don't like the colors ;-)
@@ -1967,6 +2084,12 @@ sub print_ornamented {
     my $longest = 0;
     return unless defined $what;
 
+    local $| = 1; # Flush immediately
+    if ( $CPAN::Be_Silent ) {
+        print {report_fh()} $what;
+        return;
+    }
+
     if ($CPAN::Config->{term_is_latin}){
         # courtesy jhi:
         $what
@@ -2043,13 +2166,13 @@ sub setup_output {
 sub rematein {
     shift;
     my($meth,@some) = @_;
-    my $pragma = "";
-    if ($meth eq 'force') {
-       $pragma = $meth;
+    my @pragma;
+    while($meth =~ /^(force|notest)$/) {
+       push @pragma, $meth;
        $meth = shift @some;
     }
     setup_output();
-    CPAN->debug("pragma[$pragma]meth[$meth] some[@some]") if $CPAN::DEBUG;
+    CPAN->debug("pragma[@pragma]meth[$meth]some[@some]") if $CPAN::DEBUG;
 
     # Here is the place to set "test_count" on all involved parties to
     # 0. We then can pass this counter on to the involved
@@ -2085,8 +2208,8 @@ sub rematein {
             $obj->color_cmd_tmps(0,1);
             CPAN::Queue->new($obj->id);
             push @qcopy, $obj;
-       } elsif ($CPAN::META->exists('CPAN::Author',$s)) {
-           $obj = $CPAN::META->instance('CPAN::Author',$s);
+       } elsif ($CPAN::META->exists('CPAN::Author',uc($s))) {
+           $obj = $CPAN::META->instance('CPAN::Author',uc($s));
             if ($meth =~ /^(dump|ls)$/) {
                 $obj->$meth();
             } else {
@@ -2122,19 +2245,21 @@ to find objects with matching identifiers.
        } else {
            $obj = CPAN::Shell->expandany($s);
        }
-        if ($pragma
-            &&
-            ($] < 5.00303 || $obj->can($pragma))){
-            ### compatibility with 5.003
-            $obj->$pragma($meth); # the pragma "force" in
-                                  # "CPAN::Distribution" must know
-                                  # what we are intending
+       for my $pragma (@pragma) {
+           if ($pragma
+               &&
+               ($] < 5.00303 || $obj->can($pragma))){
+               ### compatibility with 5.003
+               $obj->$pragma($meth); # the pragma "force" in
+                                      # "CPAN::Distribution" must know
+                                      # what we are intending
+           }
         }
         if ($]>=5.00303 && $obj->can('called_for')) {
             $obj->called_for($s);
         }
         CPAN->debug(
-                    qq{pragma[$pragma]meth[$meth]obj[$obj]as_string\[}.
+                    qq{pragma[@pragma]meth[$meth]obj[$obj]as_string\[}.
                     $obj->as_string.
                     qq{\]}
                    ) if $CPAN::DEBUG;
@@ -2153,26 +2278,24 @@ to find objects with matching identifiers.
     }
 }
 
-#-> sub CPAN::Shell::dump ;
-sub dump    { shift->rematein('dump',@_); }
-#-> sub CPAN::Shell::force ;
-sub force   { shift->rematein('force',@_); }
-#-> sub CPAN::Shell::get ;
-sub get     { shift->rematein('get',@_); }
-#-> sub CPAN::Shell::readme ;
-sub readme  { shift->rematein('readme',@_); }
-#-> sub CPAN::Shell::make ;
-sub make    { shift->rematein('make',@_); }
-#-> sub CPAN::Shell::test ;
-sub test    { shift->rematein('test',@_); }
-#-> sub CPAN::Shell::install ;
-sub install { shift->rematein('install',@_); }
-#-> sub CPAN::Shell::clean ;
-sub clean   { shift->rematein('clean',@_); }
-#-> sub CPAN::Shell::look ;
-sub look   { shift->rematein('look',@_); }
-#-> sub CPAN::Shell::cvs_import ;
-sub cvs_import   { shift->rematein('cvs_import',@_); }
+#-> sub CPAN::Shell::recent ;
+sub recent {
+  my($self) = @_;
+
+  CPAN::Distribution::_display_url( $self, $CPAN::Defaultrecent );
+  return;
+}
+
+{
+    # set up the dispatching methods
+    no strict "refs";
+    for my $command (qw(
+                        clean cvs_import dump force get install look
+                        make notest perldoc readme test
+                       )) {
+        *$command = sub { shift->rematein($command, @_); };
+    }
+}
 
 package CPAN::LWP::UserAgent;
 
@@ -2192,7 +2315,7 @@ sub get_basic_credentials {
     return unless $proxy;
     if ($USER && $PASSWD) {
     } elsif (defined $CPAN::Config->{proxy_user} &&
-        defined $CPAN::Config->{proxy_pass}) {
+             defined $CPAN::Config->{proxy_pass}) {
         $USER = $CPAN::Config->{proxy_user};
         $PASSWD = $CPAN::Config->{proxy_pass};
     } else {
@@ -2217,6 +2340,36 @@ sub get_basic_credentials {
     return($USER,$PASSWD);
 }
 
+# mirror(): Its purpose is to deal with proxy authentication. When we
+# call SUPER::mirror, we relly call the mirror method in
+# LWP::UserAgent. LWP::UserAgent will then call
+# $self->get_basic_credentials or some equivalent and this will be
+# $self->dispatched to our own get_basic_credentials method.
+
+# Our own get_basic_credentials sets $USER and $PASSWD, two globals.
+
+# 407 stands for HTTP_PROXY_AUTHENTICATION_REQUIRED. Which means
+# although we have gone through our get_basic_credentials, the proxy
+# server refuses to connect. This could be a case where the username or
+# password has changed in the meantime, so I'm trying once again without
+# $USER and $PASSWD to give the get_basic_credentials routine another
+# chance to set $USER and $PASSWD.
+
+# mirror(): Its purpose is to deal with proxy authentication. When we
+# call SUPER::mirror, we relly call the mirror method in
+# LWP::UserAgent. LWP::UserAgent will then call
+# $self->get_basic_credentials or some equivalent and this will be
+# $self->dispatched to our own get_basic_credentials method.
+
+# Our own get_basic_credentials sets $USER and $PASSWD, two globals.
+
+# 407 stands for HTTP_PROXY_AUTHENTICATION_REQUIRED. Which means
+# although we have gone through our get_basic_credentials, the proxy
+# server refuses to connect. This could be a case where the username or
+# password has changed in the meantime, so I'm trying once again without
+# $USER and $PASSWD to give the get_basic_credentials routine another
+# chance to set $USER and $PASSWD.
+
 sub mirror {
     my($self,$url,$aslocal) = @_;
     my $result = $self->SUPER::mirror($url,$aslocal);
@@ -2593,25 +2746,32 @@ sub hosthard {
                                            # success above. Likely a bogus URL
 
        $self->debug("localizing funkyftpwise[$url]") if $CPAN::DEBUG;
-       my($f,$funkyftp);
-       for $f ('lynx','ncftpget','ncftp','wget') {
-         next unless exists $CPAN::Config->{$f};
-         $funkyftp = $CPAN::Config->{$f};
-         next unless defined $funkyftp;
+
+        # Try the most capable first and leave ncftp* for last as it only 
+        # does FTP.
+       for my $f (qw(curl wget lynx ncftpget ncftp)) {
+          my $funkyftp = $CPAN::Config->{$f};
+          next unless defined $funkyftp;
          next if $funkyftp =~ /^\s*$/;
+
          my($asl_ungz, $asl_gz);
          ($asl_ungz = $aslocal) =~ s/\.gz//;
           $asl_gz = "$asl_ungz.gz";
+
          my($src_switch) = "";
+         my($chdir) = "";
+         my($stdout_redir) = " > $asl_ungz";
          if ($f eq "lynx"){
            $src_switch = " -source";
          } elsif ($f eq "ncftp"){
            $src_switch = " -c";
-          } elsif ($f eq "wget"){
-              $src_switch = " -O -";
+         } elsif ($f eq "wget"){
+           $src_switch = " -O $asl_ungz";
+           $stdout_redir = "";
+         } elsif ($f eq 'curl'){
+           $src_switch = ' -L';
          }
-         my($chdir) = "";
-         my($stdout_redir) = " > $asl_ungz";
+
          if ($f eq "ncftpget"){
            $chdir = "cd $aslocal_dir && ";
            $stdout_redir = "";
@@ -2685,7 +2845,7 @@ returned status $estatus (wstat $wstatus)$size
 });
          }
           return if $CPAN::Signal;
-       } # lynx,ncftpget,ncftp
+       } # transfer programs
     } # host
 }
 
@@ -2974,7 +3134,7 @@ sub cpl {
     } elsif ($line =~ /^d\s/) {
        @return = cplx('CPAN::Distribution',$word);
     } elsif ($line =~ m/^(
-                          [mru]|make|clean|dump|get|test|install|readme|look|cvs_import
+                          [mru]|make|clean|dump|get|test|install|readme|look|cvs_import|perldoc|recent
                          )\s/x ) {
         if ($word =~ /^Bundle::/) {
             CPAN::Shell->local_bundles;
@@ -3042,7 +3202,8 @@ sub cpl_option {
     } elsif ($words[1] eq 'conf') {
        return CPAN::Config::cpl(@_);
     } elsif ($words[1] eq 'debug') {
-       return sort grep /^\Q$word\E/, sort keys %CPAN::DEBUG, 'all';
+       return sort grep /^\Q$word\E/,
+            sort keys %CPAN::DEBUG, 'all';
     }
 }
 
@@ -3163,7 +3324,7 @@ sub rd_authindex {
     return unless defined $index_target;
     $CPAN::Frontend->myprint("Going to read $index_target\n");
     local(*FH);
-    tie *FH, CPAN::Tarzip, $index_target;
+    tie *FH, 'CPAN::Tarzip', $index_target;
     local($/) = "\n";
     push @lines, split /\012/ while <FH>;
     foreach (@lines) {
@@ -3241,7 +3402,7 @@ happen.\a
                       $last_updated);
         $DATE_OF_02 = $last_updated;
 
-        if ($CPAN::META->has_inst(HTTP::Date)) {
+        if ($CPAN::META->has_inst('HTTP::Date')) {
             require HTTP::Date;
             my($age) = (time - HTTP::Date::str2time($last_updated))/3600/24;
             if ($age > 30) {
@@ -3315,9 +3476,13 @@ happen.\a
 
        }
 
-       if ($id->cpan_file ne $dist){ # update only if file is
-                                      # different. CPAN prohibits same
-                                      # name with different version
+        # Although CPAN prohibits same name with different version the
+        # indexer may have changed the version for the same distro
+        # since the last time ("Force Reindexing" feature)
+       if ($id->cpan_file ne $dist
+            ||
+            $id->cpan_version ne $version
+           ){
            $userid = $id->userid || $self->userid($dist);
            $id->set(
                     'CPAN_USERID' => $userid,
@@ -3631,28 +3796,29 @@ sub email    { shift->{RO}{EMAIL}; }
 #-> sub CPAN::Author::ls ;
 sub ls {
     my $self = shift;
+    my $silent = shift || 0;
     my $id = $self->id;
 
     # adapted from CPAN::Distribution::verifyMD5 ;
     my(@csf); # chksumfile
     @csf = $self->id =~ /(.)(.)(.*)/;
     $csf[1] = join "", @csf[0,1];
-    $csf[2] = join "", @csf[1,2];
+    $csf[2] = join "", @csf[1,2]; # ("A","AN","ANDK")
     my(@dl);
-    @dl = $self->dir_listing([$csf[0],"CHECKSUMS"], 0);
+    @dl = $self->dir_listing([$csf[0],"CHECKSUMS"], 0, 1);
     unless (grep {$_->[2] eq $csf[1]} @dl) {
-        $CPAN::Frontend->myprint("No files in the directory of $id\n");
+        $CPAN::Frontend->myprint("Directory $csf[1]/ does not exist\n") unless $silent ;
         return;
     }
-    @dl = $self->dir_listing([@csf[0,1],"CHECKSUMS"], 0);
+    @dl = $self->dir_listing([@csf[0,1],"CHECKSUMS"], 0, 1);
     unless (grep {$_->[2] eq $csf[2]} @dl) {
-        $CPAN::Frontend->myprint("No files in the directory of $id\n");
+        $CPAN::Frontend->myprint("Directory $id/ does not exist\n") unless $silent;
         return;
     }
-    @dl = $self->dir_listing([@csf,"CHECKSUMS"], 1);
+    @dl = $self->dir_listing([@csf,"CHECKSUMS"], 1, 1);
     $CPAN::Frontend->myprint(join "", map {
         sprintf("%8d %10s %s/%s\n", $_->[0], $_->[1], $id, $_->[2])
-    } sort { $a->[2] cmp $b->[2] } @dl);
+    } sort { $a->[2] cmp $b->[2] } @dl) unless $silent;
 }
 
 # returns an array of arrays, the latter contain (size,mtime,filename)
@@ -3661,32 +3827,57 @@ sub dir_listing {
     my $self = shift;
     my $chksumfile = shift;
     my $recursive = shift;
+    my $may_ftp = shift;
     my $lc_want =
        File::Spec->catfile($CPAN::Config->{keep_source_where},
                            "authors", "id", @$chksumfile);
+
+    my $fh;
+
+    # Purge and refetch old (pre-PGP) CHECKSUMS; they are a security
+    # hazard.  (Without GPG installed they are not that much better,
+    # though.)
+    $fh = FileHandle->new;
+    if (open($fh, $lc_want)) {
+       my $line = <$fh>; close $fh;
+       unlink($lc_want) unless $line =~ /PGP/;
+    }
+
     local($") = "/";
     # connect "force" argument with "index_expire".
     my $force = 0;
     if (my @stat = stat $lc_want) {
         $force = $stat[9] + $CPAN::Config->{index_expire}*86400 <= time;
     }
-    my $lc_file = CPAN::FTP->localize("authors/id/@$chksumfile",
-                                      $lc_want,$force);
-    unless ($lc_file) {
-        $CPAN::Frontend->myprint("Trying $lc_want.gz\n");
-       $chksumfile->[-1] .= ".gz";
-       $lc_file = CPAN::FTP->localize("authors/id/@$chksumfile",
-                                       "$lc_want.gz",1);
-       if ($lc_file) {
-           $lc_file =~ s{\.gz(?!\n)\Z}{}; #};
-           CPAN::Tarzip->gunzip("$lc_file.gz",$lc_file);
-       } else {
-           return;
-       }
+    my $lc_file;
+    if ($may_ftp) {
+        $lc_file = CPAN::FTP->localize(
+                                       "authors/id/@$chksumfile",
+                                       $lc_want,
+                                       $force,
+                                      );
+        unless ($lc_file) {
+            $CPAN::Frontend->myprint("Trying $lc_want.gz\n");
+            $chksumfile->[-1] .= ".gz";
+            $lc_file = CPAN::FTP->localize("authors/id/@$chksumfile",
+                                           "$lc_want.gz",1);
+            if ($lc_file) {
+                $lc_file =~ s{\.gz(?!\n)\Z}{}; #};
+                CPAN::Tarzip->gunzip("$lc_file.gz",$lc_file);
+            } else {
+                return;
+            }
+        }
+    } else {
+        $lc_file = $lc_want;
+        # we *could* second-guess and if the user has a file: URL,
+        # then we could look there. But on the other hand, if they do
+        # have a file: URL, wy did they choose to set
+        # $CPAN::Config->{show_upload_date} to false?
     }
 
     # adapted from CPAN::Distribution::MD5_check_file ;
-    my $fh = FileHandle->new;
+    $fh = FileHandle->new;
     my($cksum);
     if (open $fh, $lc_file){
        local($/);
@@ -3699,8 +3890,11 @@ sub dir_listing {
            rename $lc_file, "$lc_file.bad";
            Carp::confess($@) if $@;
        }
+    } elsif ($may_ftp) {
+       Carp::carp "Could not open $lc_file for reading.";
     } else {
-       Carp::carp "Could not open $lc_file for reading";
+        # Maybe should warn: "You may want to set show_upload_date to a true value"
+       return;
     }
     my(@result,$f);
     for $f (sort keys %$cksum) {
@@ -3711,7 +3905,7 @@ sub dir_listing {
                 push @dir, $f, "CHECKSUMS";
                 push @result, map {
                     [$_->[0], $_->[1], "$f/$_->[2]"]
-                } $self->dir_listing(\@dir,1);
+                } $self->dir_listing(\@dir,1,$may_ftp);
             } else {
                 push @result, [ 0, "-", $f ];
             }
@@ -3785,6 +3979,7 @@ sub color_cmd_tmps {
 sub as_string {
   my $self = shift;
   $self->containsmods;
+  $self->upload_date;
   $self->SUPER::as_string(@_);
 }
 
@@ -3803,6 +3998,23 @@ sub containsmods {
   keys %{$self->{CONTAINSMODS}};
 }
 
+#-> sub CPAN::Distribution::upload_date ;
+sub upload_date {
+  my $self = shift;
+  return $self->{UPLOAD_DATE} if exists $self->{UPLOAD_DATE};
+  my(@local_wanted) = split(/\//,$self->id);
+  my $filename = pop @local_wanted;
+  push @local_wanted, "CHECKSUMS";
+  my $author = CPAN::Shell->expand("Author",$self->cpan_userid);
+  return unless $author;
+  my @dl = $author->dir_listing(\@local_wanted,0,$CPAN::Config->{show_upload_date});
+  return unless @dl;
+  my($dirent) = grep { $_->[2] eq $filename } @dl;
+  # warn sprintf "dirent[%s]id[%s]", $dirent, $self->id;
+  return unless $dirent->[1];
+  return $self->{UPLOAD_DATE} = $dirent->[1];
+}
+
 #-> sub CPAN::Distribution::uptodate ;
 sub uptodate {
     my($self) = @_;
@@ -3905,13 +4117,15 @@ sub get {
     #
     # Unpack the goods
     #
+    $self->debug("local_file[$local_file]") if $CPAN::DEBUG;
     if ($local_file =~ /(\.tar\.(gz|Z)|\.tgz)(?!\n)\Z/i){
         $self->{was_uncompressed}++ unless CPAN::Tarzip->gtest($local_file);
        $self->untar_me($local_file);
     } elsif ( $local_file =~ /\.zip(?!\n)\Z/i ) {
        $self->unzip_me($local_file);
-    } elsif ( $local_file =~ /\.pm\.(gz|Z)(?!\n)\Z/) {
+    } elsif ( $local_file =~ /\.pm(\.(gz|Z))?(?!\n)\Z/) {
         $self->{was_uncompressed}++ unless CPAN::Tarzip->gtest($local_file);
+        $self->debug("calling pm2dir for local_file[$local_file]") if $CPAN::DEBUG;
        $self->pm2dir_me($local_file);
     } else {
        $self->{archived} = "NO";
@@ -3934,9 +4148,9 @@ sub get {
         -d $packagedir and $CPAN::Frontend->myprint("Removing previously used ".
                                                     "$packagedir\n");
         File::Path::rmtree($packagedir);
-        rename($distdir,$packagedir) or
-            Carp::confess("Couldn't rename $distdir to $packagedir: $!");
-        $self->debug(sprintf("renamed distdir[%s] to packagedir[%s] -e[%s]-d[%s]",
+        File::Copy::move($distdir,$packagedir) or
+            Carp::confess("Couldn't move $distdir to $packagedir: $!");
+        $self->debug(sprintf("moved distdir[%s] to packagedir[%s] -e[%s]-d[%s]",
                              $distdir,
                              $packagedir,
                              -e $packagedir,
@@ -3957,7 +4171,7 @@ sub get {
         my($f);
         for $f (@readdir) { # is already without "." and ".."
             my $to = File::Spec->catdir($packagedir,$f);
-            rename($f,$to) or Carp::confess("Couldn't rename $f to $to: $!");
+            File::Copy::move($f,$to) or Carp::confess("Couldn't move $f to $to: $!");
         }
     }
     if ($CPAN::Signal){
@@ -3966,9 +4180,44 @@ sub get {
     }
 
     $self->{'build_dir'} = $packagedir;
-    $self->safe_chdir(File::Spec->updir);
+    $self->safe_chdir($builddir);
     File::Path::rmtree("tmp");
 
+    $self->safe_chdir($packagedir);
+    if ($CPAN::META->has_inst("Module::Signature")) {
+        if (-f "SIGNATURE") {
+            $self->debug("Module::Signature is installed, verifying") if $CPAN::DEBUG;
+            my $rv = Module::Signature::verify();
+            if ($rv != Module::Signature::SIGNATURE_OK() and
+                $rv != Module::Signature::SIGNATURE_MISSING()) {
+                $CPAN::Frontend->myprint(
+                                         qq{\nSignature invalid for }.
+                                         qq{distribution file. }.
+                                         qq{Please investigate.\n\n}.
+                                         $self->as_string,
+                                         $CPAN::META->instance(
+                                                               'CPAN::Author',
+                                                               $self->cpan_userid,
+                                                              )->as_string
+                                        );
+
+                my $wrap = qq{I\'d recommend removing $self->{localfile}. Its signature
+is invalid. Maybe you have configured your 'urllist' with
+a bad URL. Please check this array with 'o conf urllist', and
+retry.};
+                $CPAN::Frontend->mydie(Text::Wrap::wrap("","",$wrap));
+            }
+        } else {
+            $CPAN::Frontend->myprint(qq{Package came without SIGNATURE\n\n});
+        }
+    } else {
+       $self->debug("Module::Signature is NOT installed") if $CPAN::DEBUG;
+    }
+    $self->safe_chdir($builddir);
+    return if $CPAN::Signal;
+
+
+
     my($mpl) = File::Spec->catfile($packagedir,"Makefile.PL");
     my($mpl_exists) = -f $mpl;
     unless ($mpl_exists) {
@@ -4059,11 +4308,15 @@ sub pm2dir_me {
     my($self,$local_file) = @_;
     $self->{archived} = "pm";
     my $to = File::Basename::basename($local_file);
-    $to =~ s/\.(gz|Z)(?!\n)\Z//;
-    if (CPAN::Tarzip->gunzip($local_file,$to)) {
-       $self->{unwrapped} = "YES";
+    if ($to =~ s/\.(gz|Z)(?!\n)\Z//) {
+        if (CPAN::Tarzip->gunzip($local_file,$to)) {
+            $self->{unwrapped} = "YES";
+        } else {
+            $self->{unwrapped} = "NO";
+        }
     } else {
-       $self->{unwrapped} = "NO";
+        File::Copy::cp($local_file,".");
+        $self->{unwrapped} = "YES";
     }
 }
 
@@ -4193,6 +4446,7 @@ with pager "$CPAN::Config->{'pager'}"
 });
     sleep 2;
     $fh_pager->print(<$fh_readme>);
+    $fh_pager->close;
 }
 
 #-> sub CPAN::Distribution::verifyMD5 ;
@@ -4236,10 +4490,44 @@ sub verifyMD5 {
     $self->MD5_check_file($lc_file);
 }
 
+sub SIG_check_file {
+    my($self,$chk_file) = @_;
+    my $rv = eval { Module::Signature::_verify($chk_file) };
+
+    if ($rv == Module::Signature::SIGNATURE_OK()) {
+       $CPAN::Frontend->myprint("Signature for $chk_file ok\n");
+       return $self->{SIG_STATUS} = "OK";
+    } else {
+       $CPAN::Frontend->myprint(qq{\nSignature invalid for }.
+                                qq{distribution file. }.
+                                qq{Please investigate.\n\n}.
+                                $self->as_string,
+                               $CPAN::META->instance(
+                                                       'CPAN::Author',
+                                                       $self->cpan_userid
+                                                       )->as_string);
+
+       my $wrap = qq{I\'d recommend removing $chk_file. Its signature
+is invalid. Maybe you have configured your 'urllist' with
+a bad URL. Please check this array with 'o conf urllist', and
+retry.};
+
+       $CPAN::Frontend->mydie(Text::Wrap::wrap("","",$wrap));
+    }
+}
+
 #-> sub CPAN::Distribution::MD5_check_file ;
 sub MD5_check_file {
     my($self,$chk_file) = @_;
     my($cksum,$file,$basename);
+
+    if ($CPAN::META->has_inst("Module::Signature") and Module::Signature->VERSION >= 0.26) {
+       $self->debug("Module::Signature is installed, verifying");
+       $self->SIG_check_file($chk_file);
+    } else {
+       $self->debug("Module::Signature is NOT installed");
+    }
+
     $file = $self->{localfile};
     $basename = File::Basename::basename($file);
     my $fh = FileHandle->new;
@@ -4366,6 +4654,18 @@ sub force {
   }
 }
 
+sub notest {
+  my($self, $method) = @_;
+  # warn "XDEBUG: set notest for $self $method";
+  $self->{"notest"}++; # name should probably have been force_install
+}
+
+sub unnotest {
+  my($self) = @_;
+  # warn "XDEBUG: deleting notest";
+  delete $self->{'notest'};
+}
+
 #-> sub CPAN::Distribution::unforce ;
 sub unforce {
   my($self) = @_;
@@ -4396,30 +4696,13 @@ sub isa_perl {
   }
 }
 
+
 #-> sub CPAN::Distribution::perl ;
 sub perl {
-    my($self) = @_;
-    my($perl) = File::Spec->file_name_is_absolute($^X) ? $^X : "";
-    my $pwd  = CPAN::anycwd();
-    my $candidate = File::Spec->catfile($pwd,$^X);
-    $perl ||= $candidate if MM->maybe_command($candidate);
-    unless ($perl) {
-       my ($component,$perl_name);
-      DIST_PERLNAME: foreach $perl_name ($^X, 'perl', 'perl5', "perl$]") {
-           PATH_COMPONENT: foreach $component (File::Spec->path(),
-                                               $Config::Config{'binexp'}) {
-                 next unless defined($component) && $component;
-                 my($abs) = File::Spec->catfile($component,$perl_name);
-                 if (MM->maybe_command($abs)) {
-                     $perl = $abs;
-                     last DIST_PERLNAME;
-                 }
-             }
-         }
-    }
-    $perl;
+    return $CPAN::Perl;
 }
 
+
 #-> sub CPAN::Distribution::make ;
 sub make {
     my($self) = @_;
@@ -4695,6 +4978,12 @@ sub test {
       delete $self->{force_update};
       return;
     }
+    # warn "XDEBUG: checking for notest: $self->{notest} $self";
+    if ($self->{notest}) {
+       $CPAN::Frontend->myprint("Skipping test because of notest pragma\n");
+       return 1;
+    }
+
     $CPAN::Frontend->myprint("Running make test\n");
     if (my @prereq = $self->unsat_prereq){
       return 1 if $self->follow_prereqs(@prereq); # signal success to the queuerunner
@@ -4728,7 +5017,10 @@ sub test {
         return;
     }
 
-    local $ENV{PERL5LIB} = $ENV{PERL5LIB} || "";
+    local $ENV{PERL5LIB} = defined($ENV{PERL5LIB})
+                           ? $ENV{PERL5LIB}
+                           : ($ENV{PERLLIB} || "");
+
     $CPAN::META->set_perl5lib;
     my $system = join " ", $CPAN::Config->{'make'}, "test";
     if (system($system) == 0) {
@@ -4837,8 +5129,14 @@ sub install {
         return;
     }
 
-    my $system = join(" ", $CPAN::Config->{'make'},
-                     "install", $CPAN::Config->{make_install_arg});
+    my($make_install_make_command) = $CPAN::Config->{'make_install_make_command'} ||
+        $CPAN::Config->{'make'};
+
+    my($system) = join(" ",
+                       $make_install_make_command,
+                       "install",
+                       $CPAN::Config->{make_install_arg},
+                      );
     my($stderr) = $^O =~ /Win/i ? "" : " 2>&1 ";
     my($pipe) = FileHandle->new("$system $stderr |");
     my($makeout) = "";
@@ -4854,9 +5152,22 @@ sub install {
     } else {
         $self->{'install'} = "NO";
         $CPAN::Frontend->myprint("  $system -- NOT OK\n");
-        if ($makeout =~ /permission/s && $> > 0) {
-            $CPAN::Frontend->myprint(qq{    You may have to su }.
-                                     qq{to root to install the package\n});
+        if (
+             $makeout =~ /permission/s
+             && $> > 0
+             && (
+                 ! $CPAN::Config->{make_install_make_command}
+                 || $CPAN::Config->{make_install_make_command} eq $CPAN::Config->{make}
+                )
+            ) {
+             $CPAN::Frontend->myprint(
+                                      qq{----\n}.
+                                      qq{  You may have to su }.
+                                      qq{to root to install the package\n}.
+                                      qq{  (Or you may want to run something like\n}.
+                                      qq{    o conf make_install_make_command 'sudo make'\n}.
+                                      qq{  to raise your permissions.}
+                                     );
         }
     }
     delete $self->{force_update};
@@ -4867,6 +5178,179 @@ sub dir {
     shift->{'build_dir'};
 }
 
+#-> sub CPAN::Distribution::perldoc ;
+sub perldoc {
+    my($self) = @_;
+
+    my($dist) = $self->id;
+    my $package = $self->called_for;
+
+    $self->_display_url( $CPAN::Defaultdocs . $package );
+}
+
+#-> sub CPAN::Distribution::_check_binary ;
+sub _check_binary {
+    my ($dist,$shell,$binary) = @_;
+    my ($pid,$readme,$out);
+
+    $CPAN::Frontend->myprint(qq{ + _check_binary($binary)\n})
+      if $CPAN::DEBUG;
+
+    $pid = open $readme, "which $binary|"
+      or $CPAN::Frontend->mydie(qq{Could not fork 'which $binary': $!});
+    while (<$readme>) {
+       $out .= $_;
+    }
+    close $readme or die "Could not run 'which $binary': $!";
+
+    $CPAN::Frontend->myprint(qq{   + $out \n})
+      if $CPAN::DEBUG && $out;
+
+    return $out;
+}
+
+#-> sub CPAN::Distribution::_display_url ;
+sub _display_url {
+    my($self,$url) = @_;
+    my($res,$saved_file,$pid,$readme,$out);
+
+    $CPAN::Frontend->myprint(qq{ + _display_url($url)\n})
+      if $CPAN::DEBUG;
+
+    # should we define it in the config instead?
+    my $html_converter = "html2text";
+
+    my $web_browser = $CPAN::Config->{'lynx'} || undef;
+    my $web_browser_out = $web_browser
+      ? CPAN::Distribution->_check_binary($self,$web_browser)
+       : undef;
+
+    my ($tmpout,$tmperr);
+    if (not $web_browser_out) {
+        # web browser not found, let's try text only
+       my $html_converter_out =
+         CPAN::Distribution->_check_binary($self,$html_converter);
+
+        if ($html_converter_out ) {
+            # html2text found, run it
+            $saved_file = CPAN::Distribution->_getsave_url( $self, $url );
+            $CPAN::Frontend->myprint(qq{ERROR: problems while getting $url, $!\n})
+              unless defined($saved_file);
+
+           $pid = open $readme, "$html_converter $saved_file |"
+             or $CPAN::Frontend->mydie(qq{
+Could not fork '$html_converter $saved_file': $!});
+           my $fh = File::Temp->new(
+                                     template => 'cpan_htmlconvert_XXXX',
+                                     suffix => '.txt',
+                                     unlink => 0,
+                                    );
+            while (<$readme>) {
+                $fh->print($_);
+            }
+           close $readme
+             or $CPAN::Frontend->mydie(qq{Could not run '$html_converter $saved_file': $!});
+            my $tmpin = $fh->filename;
+           $CPAN::Frontend->myprint(sprintf(qq{
+Run '%s %s' and
+saved output to %s\n},
+                                             $html_converter,
+                                             $saved_file,
+                                             $tmpin,
+                                            )) if $CPAN::DEBUG;
+            close $fh; undef $fh;
+           open $fh, $tmpin
+             or $CPAN::Frontend->mydie(qq{Could not open "$tmpin": $!});
+            my $fh_pager = FileHandle->new;
+            local($SIG{PIPE}) = "IGNORE";
+            $fh_pager->open("|$CPAN::Config->{'pager'}")
+              or $CPAN::Frontend->mydie(qq{
+Could not open pager $CPAN::Config->{'pager'}: $!});
+           $CPAN::Frontend->myprint(qq{
+Displaying URL
+  $url
+with pager "$CPAN::Config->{'pager'}"
+});
+           sleep 2;
+            $fh_pager->print(<$fh>);
+           $fh_pager->close;
+        } else {
+            # coldn't find the web browser or html converter
+            $CPAN::Frontend->myprint(qq{
+You need to install lynx or $html_converter to use this feature.});
+        }
+    } else {
+        # web browser found, run the action
+       my $browser = $CPAN::Config->{'lynx'};
+        $CPAN::Frontend->myprint(qq{system[$browser $url]})
+         if $CPAN::DEBUG;
+       $CPAN::Frontend->myprint(qq{
+Displaying URL
+  $url
+with browser $browser
+});
+       sleep 2;
+        system("$browser $url");
+       if ($saved_file) { 1 while unlink($saved_file) }
+    }
+}
+
+#-> sub CPAN::Distribution::_getsave_url ;
+sub _getsave_url {
+    my($dist, $shell, $url) = @_;
+
+    $CPAN::Frontend->myprint(qq{ + _getsave_url($url)\n})
+      if $CPAN::DEBUG;
+
+    my $fh  = File::Temp->new(
+                              template => "cpan_getsave_url_XXXX",
+                              suffix => ".html",
+                              unlink => 0,
+                             );
+    my $tmpin = $fh->filename;
+    if ($CPAN::META->has_usable('LWP')) {
+        $CPAN::Frontend->myprint("Fetching with LWP:
+  $url
+");
+        my $Ua;
+        CPAN::LWP::UserAgent->config;
+       eval { $Ua = CPAN::LWP::UserAgent->new; };
+       if ($@) {
+           $CPAN::Frontend->mywarn("ERROR: CPAN::LWP::UserAgent->new dies with $@\n");
+           return;
+       } else {
+           my($var);
+           $Ua->proxy('http', $var)
+                if $var = $CPAN::Config->{http_proxy} || $ENV{http_proxy};
+           $Ua->no_proxy($var)
+                if $var = $CPAN::Config->{no_proxy} || $ENV{no_proxy};
+       }
+
+        my $req = HTTP::Request->new(GET => $url);
+        $req->header('Accept' => 'text/html');
+        my $res = $Ua->request($req);
+        if ($res->is_success) {
+            $CPAN::Frontend->myprint(" + request successful.\n")
+                if $CPAN::DEBUG;
+            print $fh $res->content;
+            close $fh;
+            $CPAN::Frontend->myprint(qq{ + saved content to $tmpin \n})
+                if $CPAN::DEBUG;
+            return $tmpin;
+        } else {
+            $CPAN::Frontend->myprint(sprintf(
+                                             "LWP failed with code[%s], message[%s]\n",
+                                             $res->code,
+                                             $res->message,
+                                            ));
+            return;
+        }
+    } else {
+        $CPAN::Frontend->myprint("LWP not available\n");
+        return;
+    }
+}
+
 package CPAN::Bundle;
 
 sub look {
@@ -5082,7 +5566,7 @@ explicitly a file $s.
         $self->debug("type[$type] s[$s]") if $CPAN::DEBUG;
        my $obj = $CPAN::META->instance($type,$s);
        $obj->$meth();
-        if ($obj->isa(CPAN::Bundle)
+        if ($obj->isa('CPAN::Bundle')
             &&
             exists $obj->{install_failed}
             &&
@@ -5150,6 +5634,8 @@ sub xs_file {
 
 #-> sub CPAN::Bundle::force ;
 sub force   { shift->rematein('force',@_); }
+#-> sub CPAN::Bundle::notest ;
+sub notest  { shift->rematein('notest',@_); }
 #-> sub CPAN::Bundle::get ;
 sub get     { shift->rematein('get',@_); }
 #-> sub CPAN::Bundle::make ;
@@ -5293,8 +5779,15 @@ sub as_string {
     }
     push @m, sprintf($sprintf, 'CPAN_VERSION', $self->cpan_version)
        if $self->cpan_version;
-    push @m, sprintf($sprintf, 'CPAN_FILE', $self->cpan_file)
-       if $self->cpan_file;
+    if (my $cpan_file = $self->cpan_file){
+        push @m, sprintf($sprintf, 'CPAN_FILE', $cpan_file);
+        if (my $dist = CPAN::Shell->expand("Distribution",$cpan_file)) {
+            my $upload_date = $dist->upload_date;
+            if ($upload_date) {
+                push @m, sprintf($sprintf, 'UPLOAD_DATE', $upload_date);
+            }
+        }
+    }
     my $sprintf3 = "    %-12s %1s%1s%1s%1s (%s,%s,%s,%s)\n";
     my(%statd,%stats,%statl,%stati);
     @statd{qw,? i c a b R M S,} = qw,unknown idea
@@ -5432,7 +5925,7 @@ sub cpan_file {
                 }
                 return "Contact Author $fullname <$email>";
             } else {
-                return "UserID $userid";
+                return "Contact Author $userid (Email address not available)";
             }
         } else {
             return "N/A";
@@ -5459,6 +5952,12 @@ sub force {
     $self->{'force_update'}++;
 }
 
+sub notest {
+    my($self) = @_;
+    # warn "XDEBUG: set notest for Module";
+    $self->{'notest'}++;
+}
+
 #-> sub CPAN::Module::rematein ;
 sub rematein {
     my($self,$meth) = @_;
@@ -5482,24 +5981,32 @@ sub rematein {
     my $pack = $CPAN::META->instance('CPAN::Distribution',$cpan_file);
     $pack->called_for($self->id);
     $pack->force($meth) if exists $self->{'force_update'};
-    $pack->$meth();
+    $pack->notest($meth) if exists $self->{'notest'};
+    eval {
+       $pack->$meth();
+    };
+    my $err = $@;
     $pack->unforce if $pack->can("unforce") && exists $self->{'force_update'};
+    $pack->unnotest if $pack->can("unnotest") && exists $self->{'notest'};
     delete $self->{'force_update'};
+    delete $self->{'notest'};
+    if ($err) {
+       die $err;
+    }
 }
 
+#-> sub CPAN::Module::perldoc ;
+sub perldoc { shift->rematein('perldoc') }
 #-> sub CPAN::Module::readme ;
-sub readme { shift->rematein('readme') }
+sub readme  { shift->rematein('readme') }
 #-> sub CPAN::Module::look ;
-sub look { shift->rematein('look') }
+sub look    { shift->rematein('look') }
 #-> sub CPAN::Module::cvs_import ;
 sub cvs_import { shift->rematein('cvs_import') }
 #-> sub CPAN::Module::get ;
-sub get    { shift->rematein('get',@_); }
+sub get     { shift->rematein('get',@_) }
 #-> sub CPAN::Module::make ;
-sub make   {
-    my $self = shift;
-    $self->rematein('make');
-}
+sub make    { shift->rematein('make') }
 #-> sub CPAN::Module::test ;
 sub test   {
     my $self = shift;
@@ -5636,8 +6143,9 @@ sub gzip {
     my($buffer,$fhw);
     $fhw = FileHandle->new($read)
        or $CPAN::Frontend->mydie("Could not open $read: $!");
+       my $cwd = `pwd`;
     my $gz = Compress::Zlib::gzopen($write, "wb")
-       or $CPAN::Frontend->mydie("Cannot gzopen $write: $!\n");
+       or $CPAN::Frontend->mydie("Cannot gzopen $write: $! (pwd is $cwd)\n");
     $gz->gzwrite($buffer)
        while read($fhw,$buffer,4096) > 0 ;
     $gz->gzclose() ;
@@ -5895,87 +6403,6 @@ sub unzip {
     }
 }
 
-
-package CPAN::Version;
-# CPAN::Version::vcmp courtesy Jost Krieger
-sub vcmp {
-  my($self,$l,$r) = @_;
-  local($^W) = 0;
-  CPAN->debug("l[$l] r[$r]") if $CPAN::DEBUG;
-
-  return 0 if $l eq $r; # short circuit for quicker success
-
-  if ($l=~/^v/ <=> $r=~/^v/) {
-      for ($l,$r) {
-          next if /^v/;
-          $_ = $self->float2vv($_);
-      }
-  }
-
-  return
-      ($l ne "undef") <=> ($r ne "undef") ||
-          ($] >= 5.006 &&
-           $l =~ /^v/ &&
-           $r =~ /^v/ &&
-           $self->vstring($l) cmp $self->vstring($r)) ||
-               $l <=> $r ||
-                   $l cmp $r;
-}
-
-sub vgt {
-  my($self,$l,$r) = @_;
-  $self->vcmp($l,$r) > 0;
-}
-
-sub vstring {
-  my($self,$n) = @_;
-  $n =~ s/^v// or die "CPAN::Version::vstring() called with invalid arg [$n]";
-  pack "U*", split /\./, $n;
-}
-
-# vv => visible vstring
-sub float2vv {
-    my($self,$n) = @_;
-    my($rev) = int($n);
-    $rev ||= 0;
-    my($mantissa) = $n =~ /\.(\d{1,12})/; # limit to 12 digits to limit
-                                          # architecture influence
-    $mantissa ||= 0;
-    $mantissa .= "0" while length($mantissa)%3;
-    my $ret = "v" . $rev;
-    while ($mantissa) {
-        $mantissa =~ s/(\d{1,3})// or
-            die "Panic: length>0 but not a digit? mantissa[$mantissa]";
-        $ret .= ".".int($1);
-    }
-    # warn "n[$n]ret[$ret]";
-    $ret;
-}
-
-sub readable {
-  my($self,$n) = @_;
-  $n =~ /^([\w\-\+\.]+)/;
-
-  return $1 if defined $1 && length($1)>0;
-  # if the first user reaches version v43, he will be treated as "+".
-  # We'll have to decide about a new rule here then, depending on what
-  # will be the prevailing versioning behavior then.
-
-  if ($] < 5.006) { # or whenever v-strings were introduced
-    # we get them wrong anyway, whatever we do, because 5.005 will
-    # have already interpreted 0.2.4 to be "0.24". So even if he
-    # indexer sends us something like "v0.2.4" we compare wrongly.
-
-    # And if they say v1.2, then the old perl takes it as "v12"
-
-    $CPAN::Frontend->mywarn("Suspicious version string seen [$n]\n");
-    return $n;
-  }
-  my $better = sprintf "v%vd", $n;
-  CPAN->debug("n[$n] better[$better]") if $CPAN::DEBUG;
-  return $better;
-}
-
 package CPAN;
 
 1;
@@ -6105,8 +6532,8 @@ the module doesn't need to be updated.
 
 CPAN also keeps track of what it has done within the current session
 and doesn't try to build a package a second time regardless if it
-succeeded or not. The C<force> command takes as a first argument the
-method to invoke (currently: C<make>, C<test>, or C<install>) and executes the
+succeeded or not. The C<force> pragma may precede another command
+(currently: C<make>, C<test>, or C<install>) and executes the
 command from scratch.
 
 Example:
@@ -6119,18 +6546,27 @@ Example:
     OpenGL-0.4/COPYRIGHT
     [...]
 
+The C<notest> pragma may be set to skip the test part in the build
+process.
+
+Example:
+
+    cpan> notest install Tk
+
 A C<clean> command results in a
 
   make clean
 
 being executed within the distribution file's working directory.
 
-=item get, readme, look module or distribution
+=item get, readme, perldoc, look module or distribution
 
 C<get> downloads a distribution file without further action. C<readme>
 displays the README file of the associated distribution. C<Look> gets
 and untars (if not yet done) the distribution file, changes to the
 appropriate directory and opens a subshell process in that directory.
+C<perldoc> displays the pod documentation of the module in html or
+plain text format.
 
 =item ls author
 
@@ -6497,6 +6933,15 @@ otherwise.
 Downloads the README file associated with a distribution and runs it
 through the pager specified in C<$CPAN::Config->{pager}>.
 
+=item CPAN::Distribution::perldoc()
+
+Downloads the pod documentation of the file associated with a
+distribution (in html format) and runs it through the external
+command lynx specified in C<$CPAN::Config->{lynx}>. If lynx
+isn't available, it converts it to plain text with external
+command html2text and runs it through the pager specified
+in C<$CPAN::Config->{pager}>
+
 =item CPAN::Distribution::test()
 
 Changes to the directory where the distribution has been unpacked and
@@ -6600,6 +7045,10 @@ if it is not installed.
 
 Runs a C<readme> on the distribution associated with this module.
 
+=item CPAN::Module::perldoc()
+
+Runs a C<perldoc> on this module.
+
 =item CPAN::Module::test()
 
 Runs a C<test> on the distribution associated with this module.
@@ -6744,7 +7193,7 @@ added to the search path of the CPAN module before the use() or
 require() statements.
 
 The configuration dialog can be started any time later again by
-issueing the command C< o conf init > in the CPAN shell.
+issuing the command C< o conf init > in the CPAN shell.
 
 Currently the following keys in the hash reference $CPAN::Config are
 defined:
@@ -6766,6 +7215,9 @@ defined:
   keep_source_where  directory in which to keep the source (if we do)
   make               location of external make program
   make_arg          arguments that should always be passed to 'make'
+  make_install_make_command
+                     the make command for running 'make install', for
+                     example 'sudo make'
   make_install_arg   same as make_arg for 'make install'
   makepl_arg        arguments passed to 'perl Makefile.PL'
   pager              location of external program more (or any pager)
@@ -6893,7 +7345,7 @@ untended.
 
 Thanks to Graham Barr for contributing the following paragraphs about
 the interaction between perl, and various firewall configurations. For
-further informations on firewalls, it is recommended to consult the
+further information on firewalls, it is recommended to consult the
 documentation that comes with the ncftp program. If you are unable to
 go through the firewall with a simple Perl setup, it is very likely
 that you can configure ncftp so that it works for your firewall.
@@ -6983,6 +7435,21 @@ like
 
 Your mileage may vary...
 
+=head1 Cryptographically signed modules
+
+Since release 1.77 CPAN.pm has been able to verify cryptographically
+signed module distributions using Module::Signature.  The CPAN modules
+can be signed by their authors, thus giving more security.  The simple
+unsigned MD5 checksums that were used before by CPAN protect mainly
+against accidental file corruption.
+
+You will need to have Module::Signature installed, which in turn
+requires that you have at least one of Crypt::OpenPGP module or the
+command-line F<gpg> tool installed.
+
+You will also need to be able to connect over the Internet to the public
+keyservers, like pgp.mit.edu, and their port 11731 (the HKP protocol).
+
 =head1 FAQ
 
 =over 4
@@ -7044,12 +7511,20 @@ so that STDOUT is captured in a file for later inspection.
 
 I am not root, how can I install a module in a personal directory?
 
+First of all, you will want to use your own configuration, not the one
+that your root user installed. The following command sequence is a
+possible approach:
+
+    % mkdir -p $HOME/.cpan/CPAN
+    % echo '$CPAN::Config={ };' > $HOME/.cpan/CPAN/MyConfig.pm
+    % cpan
+    [...answer all questions...]
+
 You will most probably like something like this:
 
   o conf makepl_arg "LIB=~/myperl/lib \
                     INSTALLMAN1DIR=~/myperl/man/man1 \
                     INSTALLMAN3DIR=~/myperl/man/man3"
-  install Sybase::Sybperl
 
 You can make this setting permanent like all C<o conf> settings with
 C<o conf commit>.
@@ -7087,7 +7562,7 @@ CPAN.pm does not know the dependency tree in advance and cannot sort
 the queue of things to install in a topologically correct order. It
 resolves perfectly well IFF all modules declare the prerequisites
 correctly with the PREREQ_PM attribute to MakeMaker. For bundles which
-fail and you need to install often, it is recommended sort the Bundle
+fail and you need to install often, it is recommended to sort the Bundle
 definition file manually. It is planned to improve the metadata
 situation for dependencies on CPAN in general, but this will still
 take some time.
@@ -7124,6 +7599,41 @@ would be
 Extended support for converters will be made available as soon as perl
 becomes stable with regard to charset issues.
 
+=item 11)
+
+When an install fails for some reason and then I correct the error
+condition and retry, CPAN.pm refuses to install the module, saying
+C<Already tried without success>.
+
+Use the force pragma like so
+
+  force install Foo::Bar
+
+This does a bit more than really needed because it untars the
+distribution again and runs make and test and only then install.
+
+Or you can use
+
+  look Foo::Bar
+
+and then 'make install' directly in the subshell.
+
+Or you leave the CPAN shell and start it again.
+
+Or, if you're not really sure and just want to run some make, test or
+install command without this pesky error message, say C<force get
+Foo::Bar> first and then continue as always. C<Force get> I<forgets>
+previous error conditions.
+
+For the really curious, by accessing internals directly, you I<could>
+
+  ! delete  CPAN::Shell->expand("Distribution", \
+    CPAN::Shell->expand("Module","Foo::Bar") \
+    ->{RO}{CPAN_FILE})->{install}
+
+but this is neither guaranteed to work in the future nor is it a
+decent command.
+
 =back
 
 =head1 BUGS