⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpan.pm

📁 MSYS在windows下模拟了一个类unix的终端
💻 PM
📖 第 1 页 / 共 5 页
字号:
            $bdir = MM->catdir($incdir,split /::/, $bbase);            CPAN->debug("bdir[$bdir]\@bbase[@bbase]") if $CPAN::DEBUG;            if ($dh = DirHandle->new($bdir)) { # may fail                my($entry);                for $entry ($dh->read) {                    next if $entry =~ /^\./;                    if (-d MM->catdir($bdir,$entry)){                        push @bbase, "$bbase\::$entry";                    } else {                        next unless $entry =~ s/\.pm(?!\n)\Z//;                        $CPAN::META->instance('CPAN::Bundle',"$bbase\::$entry");                    }                }            }        }    }}#-> sub CPAN::Shell::b ;sub b {    my($self,@which) = @_;    CPAN->debug("which[@which]") if $CPAN::DEBUG;    $self->local_bundles;    $CPAN::Frontend->myprint($self->format_result('Bundle',@which));}#-> sub CPAN::Shell::d ;sub d { $CPAN::Frontend->myprint(shift->format_result('Distribution',@_));}#-> sub CPAN::Shell::m ;sub m { # emacs confused here }; sub mimimimimi { # emacs in sync here    $CPAN::Frontend->myprint(shift->format_result('Module',@_));}#-> sub CPAN::Shell::i ;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) {	push @result, $self->expand($type,@args);    }    my $result = @result == 1 ?	$result[0]->as_string :            @result == 0 ?                "No objects found of any type for argument @args\n" :                    join("",                         (map {$_->as_glimpse} @result),                         scalar @result, " items found\n",                        );    $CPAN::Frontend->myprint($result);}#-> sub CPAN::Shell::o ;# CPAN::Shell::o and CPAN::Config::edit are closely related. 'o conf'# should have been called set and 'o debug' maybe 'set debug'sub o {    my($self,$o_type,@o_what) = @_;    $o_type ||= "";    CPAN->debug("o_type[$o_type] o_what[".join(" | ",@o_what)."]\n");    if ($o_type eq 'conf') {	shift @o_what if @o_what && $o_what[0] eq 'help';	if (!@o_what) { # print all things, "o conf"	    my($k,$v);	    $CPAN::Frontend->myprint("CPAN::Config options");	    if (exists $INC{'CPAN/Config.pm'}) {	      $CPAN::Frontend->myprint(" from $INC{'CPAN/Config.pm'}");	    }	    if (exists $INC{'CPAN/MyConfig.pm'}) {	      $CPAN::Frontend->myprint(" and $INC{'CPAN/MyConfig.pm'}");	    }	    $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("\n");	    for $k (sort keys %$CPAN::Config) {                CPAN::Config->prettyprint($k);	    }	    $CPAN::Frontend->myprint("\n");	} elsif (!CPAN::Config->edit(@o_what)) {	    $CPAN::Frontend->myprint(qq{Type 'o conf' to view configuration }.                                     qq{edit options\n\n});	}    } elsif ($o_type eq 'debug') {	my(%valid);	@o_what = () if defined $o_what[0] && $o_what[0] =~ /help/i;	if (@o_what) {	    while (@o_what) {		my($what) = shift @o_what;                if ($what =~ s/^-// && exists $CPAN::DEBUG{$what}) {                    $CPAN::DEBUG &= $CPAN::DEBUG ^ $CPAN::DEBUG{$what};                    next;                }		if ( exists $CPAN::DEBUG{$what} ) {		    $CPAN::DEBUG |= $CPAN::DEBUG{$what};		} elsif ($what =~ /^\d/) {		    $CPAN::DEBUG = $what;		} elsif (lc $what eq 'all') {		    my($max) = 0;		    for (values %CPAN::DEBUG) {			$max += $_;		    }		    $CPAN::DEBUG = $max;		} else {		    my($known) = 0;		    for (keys %CPAN::DEBUG) {			next unless lc($_) eq lc($what);			$CPAN::DEBUG |= $CPAN::DEBUG{$_};			$known = 1;		    }		    $CPAN::Frontend->myprint("unknown argument [$what]\n")			unless $known;		}	    }	} else {	  my $raw = "Valid options for debug are ".	      join(", ",sort(keys %CPAN::DEBUG), 'all').		  qq{ or a number. Completion works on the options. }.		      qq{Case is ignored.};	  require Text::Wrap;	  $CPAN::Frontend->myprint(Text::Wrap::fill("","",$raw));	  $CPAN::Frontend->myprint("\n\n");	}	if ($CPAN::DEBUG) {	    $CPAN::Frontend->myprint("Options set for debugging:\n");	    my($k,$v);	    for $k (sort {$CPAN::DEBUG{$a} <=> $CPAN::DEBUG{$b}} keys %CPAN::DEBUG) {		$v = $CPAN::DEBUG{$k};		$CPAN::Frontend->myprint(sprintf "    %-14s(%s)\n", $k, $v)                    if $v & $CPAN::DEBUG;	    }	} else {	    $CPAN::Frontend->myprint("Debugging turned off completely.\n");	}    } else {	$CPAN::Frontend->myprint(qq{Known options:  conf    set or get configuration variables  debug   set or get debugging options});    }}sub paintdots_onreload {    my($ref) = shift;    sub {	if ( $_[0] =~ /[Ss]ubroutine (\w+) redefined/ ) {	    my($subr) = $1;	    ++$$ref;	    local($|) = 1;	    # $CPAN::Frontend->myprint(".($subr)");	    $CPAN::Frontend->myprint(".");	    return;	}	warn @_;    };}#-> sub CPAN::Shell::reload ;sub reload {    my($self,$command,@arg) = @_;    $command ||= "";    $self->debug("self[$self]command[$command]arg[@arg]") if $CPAN::DEBUG;    if ($command =~ /cpan/i) {	CPAN->debug("reloading the whole CPAN.pm") if $CPAN::DEBUG;	my $fh = FileHandle->new($INC{'CPAN.pm'});	local($/);	my $redef = 0;	local($SIG{__WARN__}) = paintdots_onreload(\$redef);	eval <$fh>;	warn $@ if $@;	$CPAN::Frontend->myprint("\n$redef subroutines redefined\n");    } elsif ($command =~ /index/) {      CPAN::Index->force_reload;    } else {      $CPAN::Frontend->myprint(qq{cpan     re-evals the CPAN.pm fileindex    re-reads the index files\n});    }}#-> sub CPAN::Shell::_binary_extensions ;sub _binary_extensions {    my($self) = shift @_;    my(@result,$module,%seen,%need,$headerdone);    for $module ($self->expand('Module','/./')) {	my $file  = $module->cpan_file;	next if $file eq "N/A";	next if $file =~ /^Contact Author/;        my $dist = $CPAN::META->instance('CPAN::Distribution',$file);	next if $dist->isa_perl;	next unless $module->xs_file;	local($|) = 1;	$CPAN::Frontend->myprint(".");	push @result, $module;    }#    print join " | ", @result;    $CPAN::Frontend->myprint("\n");    return @result;}#-> sub CPAN::Shell::recompile ;sub recompile {    my($self) = shift @_;    my($module,@module,$cpan_file,%dist);    @module = $self->_binary_extensions();    for $module (@module){  # we force now and compile later, so we                            # don't do it twice	$cpan_file = $module->cpan_file;	my $pack = $CPAN::META->instance('CPAN::Distribution',$cpan_file);	$pack->force;	$dist{$cpan_file}++;    }    for $cpan_file (sort keys %dist) {	$CPAN::Frontend->myprint("  CPAN: Recompiling $cpan_file\n\n");	my $pack = $CPAN::META->instance('CPAN::Distribution',$cpan_file);	$pack->install;	$CPAN::Signal = 0; # it's tempting to reset Signal, so we can                           # stop a package from recompiling,                           # e.g. IO-1.12 when we have perl5.003_10    }}#-> sub CPAN::Shell::_u_r_common ;sub _u_r_common {    my($self) = shift @_;    my($what) = shift @_;    CPAN->debug("self[$self] what[$what] args[@_]") if $CPAN::DEBUG;    Carp::croak "Usage: \$obj->_u_r_common(a|r|u)" unless          $what && $what =~ /^[aru]$/;    my(@args) = @_;    @args = '/./' unless @args;    my(@result,$module,%seen,%need,$headerdone,       $version_undefs,$version_zeroes);    $version_undefs = $version_zeroes = 0;    my $sprintf = "%s%-25s%s %9s %9s  %s\n";    my @expand = $self->expand('Module',@args);    my $expand = scalar @expand;    if (0) { # Looks like noise to me, was very useful for debugging             # for metadata cache        $CPAN::Frontend->myprint(sprintf "%d matches in the database\n", $expand);    }    for $module (@expand) {	my $file  = $module->cpan_file;	next unless defined $file; # ??	my($latest) = $module->cpan_version;	my($inst_file) = $module->inst_file;	my($have);	return if $CPAN::Signal;	if ($inst_file){	    if ($what eq "a") {		$have = $module->inst_version;	    } elsif ($what eq "r") {		$have = $module->inst_version;		local($^W) = 0;		if ($have eq "undef"){		    $version_undefs++;		} elsif ($have == 0){		    $version_zeroes++;		}		next 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;	    }	} else {	    if ($what eq "a") {		next;	    } elsif ($what eq "r") {		next;	    } elsif ($what eq "u") {		$have = "-";	    }	}	return if $CPAN::Signal; # this is sometimes lengthy	$seen{$file} ||= 0;	if ($what eq "a") {	    push @result, sprintf "%s %s\n", $module->id, $have;	} elsif ($what eq "r") {	    push @result, $module->id;	    next if $seen{$file}++;	} elsif ($what eq "u") {	    push @result, $module->id;	    next if $seen{$file}++;	    next if $file =~ /^Contact/;	}	unless ($headerdone++){	    $CPAN::Frontend->myprint("\n");	    $CPAN::Frontend->myprint(sprintf(                                             $sprintf,                                             "",                                             "Package namespace",                                             "",                                             "installed",                                             "latest",                                             "in CPAN file"                                            ));	}        my $color_on = "";        my $color_off = "";        if (            $COLOR_REGISTERED            &&            $CPAN::META->has_inst("Term::ANSIColor")            &&            $module->{RO}{description}           ) {            $color_on = Term::ANSIColor::color("green");            $color_off = Term::ANSIColor::color("reset");        }	$CPAN::Frontend->myprint(sprintf $sprintf,                                 $color_on,                                 $module->id,                                 $color_off,                                 $have,                                 $latest,                                 $file);	$need{$module->id}++;    }    unless (%need) {	if ($what eq "u") {	    $CPAN::Frontend->myprint("No modules found for @args\n");	} elsif ($what eq "r") {	    $CPAN::Frontend->myprint("All modules are up to date for @args\n");	}    }    if ($what eq "r") {	if ($version_zeroes) {	    my $s_has = $version_zeroes > 1 ? "s have" : " has";	    $CPAN::Frontend->myprint(qq{$version_zeroes installed module$s_has }.		qq{a version number of 0\n});	}	if ($version_undefs) {	    my $s_has = $version_undefs > 1 ? "s have" : " has";	    $CPAN::Frontend->myprint(qq{$version_undefs installed module$s_has no }.		qq{parseable version number\n});	}    }    @result;}#-> sub CPAN::Shell::r ;sub r {    shift->_u_r_common("r",@_);}#-> sub CPAN::Shell::u ;sub u {    shift->_u_r_common("u",@_);}#-> sub CPAN::Shell::autobundle ;sub autobundle {    my($self) = shift;    CPAN::Config->load unless $CPAN::Config_loaded++;    my(@bundle) = $self->_u_r_common("a",@_);    my($todir) = MM->catdir($CPAN::Config->{'cpan_home'},"Bundle");    File::Path::mkpath($todir);    unless (-d $todir) {	$CPAN::Frontend->myprint("Couldn't mkdir $todir for some reason\n");	return;    }    my($y,$m,$d) =  (localtime)[5,4,3];    $y+=1900;    $m++;    my($c) = 0;    my($me) = sprintf "Snapshot_%04d_%02d_%02d_%02d", $y, $m, $d, $c;    my($to) = MM->catfile($todir,"$me.pm");    while (-f $to) {	$me = sprintf "Snapshot_%04d_%02d_%02d_%02d", $y, $m, $d, ++$c;	$to = MM->catfile($todir,"$me.pm");    }    my($fh) = FileHandle->new(">$to") or Carp::croak "Can't open >$to: $!";    $fh->print(	       "package Bundle::$me;\n\n",	       "\$VERSION = '0.01';\n\n",	       "1;\n\n",	       "__END__\n\n",	       "=head1 NAME\n\n",	       "Bundle::$me - Snapshot of installation on ",	       $Config::Config{'myhostname'},	       " on ",	       scalar(localtime),	       "\n\n=head1 SYNOPSIS\n\n",	       "perl -MCPAN -e 'install Bundle::$me'\n\n",	       "=head1 CONTENTS\n\n",	       join("\n", @bundle),	       "\n\n=head1 CONFIGURATION\n\n",	       Config->myconfig,	       "\n\n=head1 AUTHOR\n\n",	       "This Bundle has been generated automatically ",	       "by the autobundle routine in CPAN.pm.\n",	      );    $fh->close;    $CPAN::Frontend->myprint("\nWrote bundle file    $to\n\n");}#-> sub CPAN::Shell::expandany ;sub expandany {    my($self,$s) = @_;    CPAN->debug("s[$s]") if $CPAN::DEBUG;    if ($s =~ m|/|) { # looks like a file        $s = CPAN::Distribution->normalize($s);        return $CPAN::META->instance('CPAN::Distribution',$s);        # Distributions spring into existence, not expand    } elsif ($s =~ m|^Bundle::|) {        $self->local_bundles; # scanning so late for bundles seems                              # both attractive and crumpy: always                              # current state but easy to forget                              # somewhere        return $self->expand('Bundle',$s);    } else {        return $self->expand('Module',$s)            if $CPAN::META->exists('CPAN::Module',$s);    }    return;}#-> sub CPAN::Shell::expand ;sub expand {    shift;    my($type,@args) = @_;    my($arg,@m);    CPAN->debug("type[$type]args[@args]") if $CPAN::DEBUG;    for $arg (@args) {	my($regex,$command);	if ($arg =~ m|^/(.*)/$|) {	    $regex = $1;	} elsif ($arg =~ m/=/) {            $command = 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -