Table of Content

There is buildin perl 5.8 in msys, also got portable Strawberry perl 5.18, how to run it without remove old version?

The tough thing is msys $PATH always place below in the beginning when start new shell:
.:/usr/local/bin:/mingw/bin:/bin

then following up the $PATH from Windows env, so Strawberry perl always behind of default perl.

$ which -a perl
/bin/perl.exe
/portable/portable-perl5.18/perl/bin/perl

Here is easy solution:

1) create sbperl/back under /usr/local/bin

sbperl bash script to activate Strawberry perl

/usr/local/bin/sbperl
#!/bin/bash

OLD_PATH="$PATH"
PATH=/portable/portable-perl5.18/perl/site/bin:/portable/portable-perl5.18/perl/bin:/portable/portable-perl5.18/c/bin:$PATH
export OLD_PATH  PATH

export PS1='(sbperl) \u> \w
$ '

back bash script to deactivate Strawberry perl

/usr/local/bin/back
#!/bin/bash

export PATH=$OLD_PATH
unset OLD_PATH

export PS1='\u> \w
$ '

2) change sbperl/unsbperl permission

make sure msys can find it in path /usr/local/bin

$chmod +x /usr/local/bin/sbperl
$chmod +x /usr/local/bin/back

$ which -a sbperl
/usr/local/bin/sbperl

$ which -a back
/usr/local/bin/back

3) source sbperl/back

don’t run it directly, o/w will start new shell then no chance to put Strawberry perl in front of $PATH

$ source sbperl
(sbperl) dreamcloud> ~
$

$ echo $PATH
/portable/portable-perl5.18/perl/site/bin:/portable/portable-perl5.18/perl/bin:/portable/portable-perl5.18/c/bin:.:/usr/local/bin:/mingw/bin:/bin:

4) verify Strawberry perl 5.18 tools

$ which -a perl
/portable/portable-perl5.18/perl/bin/perl.exe
/bin/perl.exe

$ which -a perldoc
/portable/portable-perl5.18/perl/bin/perldoc
/bin/perldoc

$ perl -v

This is perl 5, version 18, subversion 4 (v5.18.4) built for MSWin32-x86-multi-thread-64int

5) deactivate Strawberry perl

$ source back