I cant read Perl and have barely any knowledge of Perl, but its part of my system and sometimes I want to try out some Perl projects, but the dependencies always a mess for me because I dont know how to cleanly remove the installed depending modules after the tryout.

This note was created primarily for how I could uninstall modules. This is not a note for coding, nor the Perl core itself. There might be mistakes in this note.

1   Modules

1.1   Installation methods

1.1.1   Build.PL
perl Build.PL

# for testing
./Build test

# dry-running
./Build fakeinstall --destdir=$HOME/.local --install_base=.

# installing
./Build     install --destdir=$HOME/.local --install_base=.

# uninstalling
./Build   uninstall --destdir=$HOME/.local --install_base=.

This is how traditionally done, but there likely is no uninstall option.

1.1.2   CPAN managers

They may require proper environment variables to be set for local installation:

export PERL_MB_OPT=$HOME/.local  # Module::Build
export PERL_MM_OPT=$HOME/.local  # ExtUtils::MakeMaker
export PERL5LIB=$PERL_MB_OPT/lib/perl5:$PERL5LIB
export PATH=$PERL_MB_OPT/bin:$PATH

Use perl -V to confirm.   cpan
# -t testin / -T no testing
# -i installing
# -I load local::lib
cpan -Iit Module::Name

There is no uninstallation as far as I know. local::lib is for creating module with PERL5LIB environment variable.   cpanm (Best option)
# installing
# -n --notest
cpanm [-l|--local-lib <path>] <source>

# uninstalling
cpanm -l $PERL_MB_OPT -U <source>

You can give cpanm (App::cpanminus) a tarball, a module name, a Git link, and some others. It will eat everything, probably even your cat.

1.2   PERL5LIB environment variable

I dont know how exactly, but the paths in PERL5LIB will be inserted at top of INC and Perl will look at those places first when searching for loading a module.

In conjunction with local::lib, PERL_MB_OPT, PERL_MM_OPT, and managers, they can be the place to install requested modules. As long as PERL5LIB is set consistently with PERL_*_OPT, the depending Perl script should run without dependency issues.

Its sort of equivalent to Gos GOPATH, except Go has a simple and uncomplicated case.