<commit_before>package App::perlbrew;
use strict;
use warnings;
use 5.008;
use Getopt::Long ();
use File::Spec::Functions qw( catfile );

our $VERSION = "0.24";
our $CONF;

my $ROOT         = $ENV{PERLBREW_ROOT} || "$ENV{HOME}/perl5/perlbrew";
my $PB_HOME      = $ENV{PERLBREW_HOME} || "$ENV{HOME}/.perlbrew";
my $CONF_FILE    = catfile( $ROOT, 'Conf.pm' );
my $CURRENT_PERL = $ENV{PERLBREW_PERL};

sub current_perl { $CURRENT_PERL || '' }

sub BASHRC_CONTENT() {
    return <<'RC';
if [[ -z "$PERLBREW_HOME" ]]; then
    export PERLBREW_HOME=$HOME/.perlbrew
fi

if [[ -f $PERLBREW_HOME/init ]]; then
    . $PERLBREW_HOME/init
fi

__perlbrew_reinit () {
    if [[ ! -d $PERLBREW_HOME ]]; then
        mkdir -p $PERLBREW_HOME
    fi

    echo '# DO NOT EDIT THIS FILE' >| $PERLBREW_HOME/init
    command perlbrew env $1 >> $PERLBREW_HOME/init
    . $PERLBREW_HOME/init
    __perlbrew_set_path
}

__perlbrew_set_path () {
    [[ -z "$PERLBREW_ROOT" ]] && return 1
    unalias perl 2>/dev/null
    export PATH_WITHOUT_PERLBREW=$(perl -e 'print join ":", grep { index($_, $ENV{PERLBREW_ROOT}) } split/:/,$ENV{PATH};')
    export PATH=$PERLBREW_PATH:$PATH_WITHOUT_PERLBREW
}
__perlbrew_set_path

perlbrew () {
    local exit_status
    local short_option
    export SHELL

    if [[ `echo $1 | awk 'BEGIN{FS=""}{print $1}'` = '-' ]]; then
        short_option=$1
        shift
    else
        short_option=""
    fi

    case $1 in
        (use)
            if [[ -z "$2" ]] ; then
                if [[ -z "$PERLBREW_PERL" ]] ; then
                    echo "No version in use; defaulting to system"
                else
                    echo "Using $PERLBREW_PERL version"
                fi
            elif [[ -x "$PERLBREW_ROOT/perls/$2/bin/perl" || "$2" = "system" ]]; then
                eval $(command perlbrew $short_option env $2)
                __perlbrew_set_path
            elif [[ -x "$PERLBREW_ROOT/perls/perl-$2/bin/perl" ]]; then
                eval $(command perlbrew $short_option env "perl-$2")
                __perlbrew_set_path<commit_msg>'unalias' seems to fail on my Ubuntu and Redhat, a similar patch was suggested here: https://bugs.launchpad.net/ubuntu/+source/zsh/+bug/305346<commit_after>package App::perlbrew;
use strict;
use warnings;
use 5.008;
use Getopt::Long ();
use File::Spec::Functions qw( catfile );

our $VERSION = "0.24";
our $CONF;

my $ROOT         = $ENV{PERLBREW_ROOT} || "$ENV{HOME}/perl5/perlbrew";
my $PB_HOME      = $ENV{PERLBREW_HOME} || "$ENV{HOME}/.perlbrew";
my $CONF_FILE    = catfile( $ROOT, 'Conf.pm' );
my $CURRENT_PERL = $ENV{PERLBREW_PERL};

sub current_perl { $CURRENT_PERL || '' }

sub BASHRC_CONTENT() {
    return <<'RC';
if [[ -z "$PERLBREW_HOME" ]]; then
    export PERLBREW_HOME=$HOME/.perlbrew
fi

if [[ -f $PERLBREW_HOME/init ]]; then
    . $PERLBREW_HOME/init
fi

__perlbrew_reinit () {
    if [[ ! -d $PERLBREW_HOME ]]; then
        mkdir -p $PERLBREW_HOME
    fi

    echo '# DO NOT EDIT THIS FILE' >| $PERLBREW_HOME/init
    command perlbrew env $1 >> $PERLBREW_HOME/init
    . $PERLBREW_HOME/init
    __perlbrew_set_path
}

__perlbrew_set_path () {
    [[ -z "$PERLBREW_ROOT" ]] && return 1
    [[ -n $(alias perl 2>/dev/null) ]] && unalias perl 2>/dev/null
    export PATH_WITHOUT_PERLBREW=$(perl -e 'print join ":", grep { index($_, $ENV{PERLBREW_ROOT}) } split/:/,$ENV{PATH};')
    export PATH=$PERLBREW_PATH:$PATH_WITHOUT_PERLBREW
}
__perlbrew_set_path

perlbrew () {
    local exit_status
    local short_option
    export SHELL

    if [[ `echo $1 | awk 'BEGIN{FS=""}{print $1}'` = '-' ]]; then
        short_option=$1
        shift
    else
        short_option=""
    fi

    case $1 in
        (use)
            if [[ -z "$2" ]] ; then
                if [[ -z "$PERLBREW_PERL" ]] ; then
                    echo "No version in use; defaulting to system"
                else
                    echo "Using $PERLBREW_PERL version"
                fi
            elif [[ -x "$PERLBREW_ROOT/perls/$2/bin/perl" || "$2" = "system" ]]; then
                eval $(command perlbrew $short_option env $2)
                __perlbrew_set_path
            elif [[ -x "$PERLBREW_ROOT/perls/perl-$2/bin/perl" ]]; then
                eval $(command perlbrew $short_option env "perl-$2")
                __perlbrew_set_path
{'fraction_non_alphanumeric': 0.14684663718873633, 'fraction_numerical': 0.011403304631138002, 'mean_word_length': 2.480161943319838, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 12, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6094929', 'n_tokens_mistral': 1688, 'n_tokens_neox': 1542, 'n_words': 352}