On 1 Mar 2019, at 10:42, Dr Eberhard W Lisse wrote:

I have started to use Homebrew's Perl and its CPAN to avoid having to
mess with the Macs Protection mechanism.

The CPAN libraries/modules are installed under ~/perl5 necesstitting to
run

PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib

and adding this to the end of ~/.profile

eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"

which sets

PERL_MB_OPT='--install_base "/Users/el/perl5"'
PERL_MM_OPT=INSTALL_BASE=/Users/el/perl5

(in my case).

I have set TM_PERL to /usr/local/bin/perl and when I run a perl program
wit CMD-R it works, unless I use a CPAN module when I get this message
(under TextMate, but NOT from the command line):

If not already done, you need to explicitly set PERL_MB_OPT and PERL_MM_OPT in TextMate, either Preferences → Variables or add them to your ~/.tm_properties file.

TextMate does not run your ~/.profile and therefore does not pick up the eval line you have there.