From: Michael G Schwern Date: Mon, 11 Jul 2005 22:41:06 +0000 (-0700) Subject: [perl #5634] CPAN.pm v1.59 chdirs before looking for perl X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=607a774baa13ac303ca6f14f03a8f1d1675eabe1;p=p5sagit%2Fp5-mst-13.2.git [perl #5634] CPAN.pm v1.59 chdirs before looking for perl From: "Michael G Schwern via RT" Message-ID: p4raw-id: //depot/perl@25142 --- diff --git a/lib/CPAN.pm b/lib/CPAN.pm index 0914e3f..ebc88ba 100644 --- a/lib/CPAN.pm +++ b/lib/CPAN.pm @@ -54,6 +54,8 @@ $CPAN::DEBUG ||= 0; $CPAN::Signal ||= 0; $CPAN::Frontend ||= "CPAN::Shell"; $CPAN::Defaultsite ||= "ftp://ftp.perl.org/pub/CPAN"; +$CPAN::Perl ||= CPAN::find_perl(); + package CPAN; use strict qw(vars); @@ -85,6 +87,7 @@ sub AUTOLOAD { } } + #-> sub CPAN::shell ; sub shell { my($self) = @_; @@ -668,6 +671,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) = @_; @@ -4411,30 +4440,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) = @_;