msh210 has asked for the wisdom of the Perl Monks concerning the following question:

Hail, O Monks.

I'm new to Macintoshes. Mine (Monterey) comes with Perl. I installed Homebrew. I then followed some advice I found somewhere and installed another copy of Perl (probably through Homebrew, but I'm not sure). Now when I run cpanm Array::Compare I'm told

Can't write to /Library/Perl/5.30 and /usr/local/bin: Installing modules to /Users/my_username_here/perl5

and the installation goes through. Then, when I try to use Array::Compare, I'm told

Can't locate Array/Compare.pm in @INC (you may need to install the Array::Compare module) (@INC contains: /opt/homebrew/Cellar/perl/5.34.0/lib/perl5/site_perl/5.34.0/darwin-thread-multi-2level /opt/homebrew/Cellar/perl/5.34.0/lib/perl5/site_perl/5.34.0 /opt/homebrew/Cellar/perl/5.34.0/lib/perl5/5.34.0/darwin-thread-multi-2level /opt/homebrew/Cellar/perl/5.34.0/lib/perl5/5.34.0 /opt/homebrew/lib/perl5/site_perl/5.34.0) at -e line 1.

All I want to do is be able to install modules using cpanm and then use them, the way I used to on Windows. What should I do?

Note, I don't mind uninstalling the copy that I installed of Perl and starting over, if that's the best way.

$_="msh210";$"=$\;@_=@{[split//,uc]}[2,0];$_="@_$\1";$\=$/;++$_[0]for$...1;print lc substr crypt($_,"@_"),1,6

Replies are listed 'Best First'.
Re: module installation woes on a Mac
by tangent (Parson) on Jul 25, 2022 at 23:10 UTC
    You need to configure your shell to use your home path - have a look at this page and this one on the Hombrew site. Personally, I use perlbrew on my Mac and it works fine.

      Thank you (both respondents)! I tried perlbrew and it seems to be working great.

      $_="msh210";$"=$\;@_=@{[split//,uc]}[2,0];$_="@_$\1";$\=$/;++$_[0]for$...1;print lc substr crypt($_,"@_"),1,6
Re: module installation woes on a Mac
by AlexP (Pilgrim) on Jul 25, 2022 at 14:47 UTC

    Hi! It looks for me like your cpan is using preinstalled perl (but i'm not shure). You could try to determine it by:

    which cpan

    As for me the best way to manage perl versions on unix is https://perlbrew.pl/. Install it, then perl and then cpanM!

      % which cpan
      /opt/homebrew/bin/cpan
      % which cpanm
      /opt/homebrew/bin/cpanm
      
      $_="msh210";$"=$\;@_=@{[split//,uc]}[2,0];$_="@_$\1";$\=$/;++$_[0]for$...1;print lc substr crypt($_,"@_"),1,6