If you already have several perl installations managed with perlbrew , the easiest approach is to simply use perlbrew exec to run the script. The -q and --with options allow you to disable extra output and select a specific version of perl to run script / job. Try something like:
perlbrew exec perl -E 'say "Hello from $]\n"' (this will show errors from earlier versions ( < 5.10 ) of perl that did not enable the -E switch by default).perlbrew exec -q --with 5.26.1 perl -E 'say "Hello from $]\n"' (this will run the command and suppress the information output).perlbrew exec -q --with 5.26.1 perl ~/script_from_heaven.pl (runs the script with the requested version of perl).perlbrew exec -q --with 5.26.1 ~/script_from_heaven.pl (runs the script with the requested or hard-coded version in the shebang script line).
I try to explicitly install PERL5LIB and use local::lib only when I need it, or for specific users or environments where I exclusively install all CPAN modules in $HOME/perl5/lib/perl5 (say, full application deployment). Otherwise, I find that perl from perlbrew quite conveniently.
A few things I found useful : setting up an alias environment for perlbrew that you want to keep stable for a particular use can be a useful way to manage multiple perls:
~/$ perlbrew alias create perl-5.24.0 stable-cronperl ~/$ perlbrew list perl-5.8.9 perl-5.10.1 perl-5.24.0 cperl-cperl-5.26.1 stable-cronperl (5.24.0) perl-5.26.1
NB : however, the alias is useful / can only be used as a stable anchor #! shebang for use at the top of your scripts if you want to make them executable:
You cannot reference an alias using --with , for example:
perlbrew exec --with stable-cronperl ~/smart_comments.pl
Report this as a problem with the documentation, and an error in the to-do list.
G. Cito
source share