sub switch_to {
my ( $self, $dist, $alias ) = @_;
die "Cannot use for alias something that starts with 'perl-'\n"
if $alias && $alias =~ /^perl-/;
die "${dist} is not installed\n" unless -d joinpath($self->root, "perls", $dist);
if ($self->env("PERLBREW_BASHRC_VERSION")) {
local $ENV{PERLBREW_PERL} = $dist;
my $HOME = $self->env('HOME');
my $pb_home = $self->env("PERLBREW_HOME") || $PERLBREW_HOME;
mkpath($pb_home);
system("$0 env $dist > " . joinpath($pb_home, "init"));
print "Switched to $dist.\n\n";
}
else {
$self->launch_sub_shell($dist);
}
}
####
# The user does not source bashrc/csh in their shell initialization.
$env{PATH} = $env{PERLBREW_PATH} . ":" . join ":", grep { !/$root\/bin/ } split ":", $ENV{PATH};
$env{MANPATH} = $env{PERLBREW_MANPATH} . ":" . join ":", grep { !/$root\/man/ }
( defined($ENV{MANPATH}) ? split(":", $ENV{MANPATH}) : () );
####
sub installed_perls {
my $self = shift;
my @result;
my $root = $self->root;
for (<$root/perls/*>) {
my ($name) = $_ =~ m/\/([^\/]+$)/;
my $executable = joinpath($_, 'bin', 'perl');
my $version_file = joinpath($_,'.version');
my $orig_version;
if ( -e $version_file ){
open my $fh, '<', $version_file;
local $/;
$orig_version = <$fh>;
chomp $orig_version;
} else {
$orig_version = `$executable -e 'print \$]'`;
if ( defined $orig_version and length $orig_version ){
if (open my $fh, '>', $version_file ){
print {$fh} $orig_version;
}
}
}
push @result, {
name => $name,
orig_version=> $orig_version,
version => $self->format_perl_version($orig_version),
is_current => ($self->current_perl eq $name) && !($self->current_lib),
libs => [ $self->local_libs($name) ],
executable => $executable
};
}
return sort { $a->{orig_version} <=> $b->{orig_version} or $a->{name} cmp $b->{name} } @result;
}
####
for (<$root/perls/*>) {
my @libs = map { substr($_, length($PERLBREW_HOME) + 6) } <$PERLBREW_HOME/libs/*>;
@perls = map { m{/([^/]+)$} } grep { -d $_ && ! -l $_ } <$root/perls/*>;
for my $executable (<$root/perls/$perl/bin/*>) {
my @build_dirs = <$root/build/*>;
my @tarballs = <$root/dists/*>;
my $executable = joinpath($self->root, "perls", $name, "bin", "perl");
mkpath($_) for (grep { ! -d $_ } map { joinpath($self->root, $_) } qw(perls dists build etc bin));
my $etc_dir = joinpath($self->root, "etc");
my $root_dir = $self->path_with_tilde($self->root);
my $target = joinpath($self->root, "bin", "perlbrew");
mkpath( joinpath($self->root, "bin" ));
my $dist_tarball_path = joinpath($self->root, "dists", $dist_tarball);
my $extracted_dir = "@{[ $self->root ]}/build/$dist_tarball_basename";
my $extract_command = "cd @{[ $self->root ]}/build; $tarx $dist_tarball";
my $dist_tarball_path = joinpath($self->root, "dists", $dist_tarball);
my $build_dir = joinpath($self->root, "build");
my $dist_extracted_dir = joinpath($self->root, "build", $candidates[0]); # take the newest one
my $dist_tarball_path = joinpath($self->root, "dists", $dist_tarball);
my $dist_tarball_path = joinpath($self->root, "dists", $dist_tarball);
my @paths = grep { index($_, $PERLBREW_HOME) < 0 && index($_, $self->root) < 0 } split /:/, $self->env($envname);
$self->{log_file} = joinpath($self->root, "build.${installation_name}${variation}${append}.log");
my $perlpath = $self->root . "/perls/$installation_name";
my $patchperl = $self->root . "/bin/patchperl";
print "Installing $dist_extracted_dir into " . $self->path_with_tilde("@{[ $self->root ]}/perls/$installation_name") . "\n\n";
my $newperl = joinpath($self->root, "perls", $installation_name, "bin", "perl");
joinpath( $self->root, 'perls', $installation_name, '.version' );
my $out = $self->root . "/bin/" . $program_name;
mkpath("@{[ $self->root ]}/bin") unless -d "@{[ $self->root ]}/bin";
my $root = $self->root;
PERLBREW_PATH => joinpath($self->root, "bin"),
PERLBREW_ROOT => $self->root
if(-d "@{[ $self->root ]}/perls/$perl_name/bin") {
$env{PERLBREW_PATH} .= ":" . joinpath($self->root, "perls", $perl_name, "bin");
$env{PERLBREW_MANPATH} = joinpath($self->root, "perls", $perl_name, "man")
my $root_dir = $self->root;
my $root = $self->root;
die "${dist} is not installed\n" unless -d joinpath($self->root, "perls", $dist);
my $root = $self->root;
my $dir = "@{[ $self->root ]}/perls/$target";
next if -l $self->root . '/perls/' . $i->{name}; # Skip Aliases
my $root = $self->root;
my $path_name = joinpath($self->root, "perls", $name);
my $path_alias = joinpath($self->root, "perls", $alias) if $alias;
joinpath( $self->root, 'Config.pm' );