Homebrew provides hundreds of Open Source Unix tools compiled for OS X, free. It can be used to install Perl

Homebrew is an alternative to Macports. In September 2021, I tried to reinstall MacPorts Perl, MySQL, and CPAN on Big Sur. It failed trying to install DBD::mysql. I was tired of this problem. I switched from Macports to Homebrew. Guess what? Still had the problem. I overcame it again after two days' work. But going forward, Homebrew looks like it will be easier to use.

Installing Homebrew

Here are instructions for setting up a 64-bit Homebrew, tested
September 2021 on macOS 11.6 Big Sur.


Apple announced that in versions of macOS after Catalina, they will not provide Python, Perl, or Ruby. (This turned out not to be true: Big Sur came with all three. Perl in Big Sur is 5.30; Homebrew installed 5.34.)

Installing Perl via Homebrew will install /usr/local/bin/perl a symlink to the Homebrew version of Perl in /usr/local/Cellar/perl/5.34.0/bin/perl. Install this before updating CPAN, and make sure that all library Perl programs and modules use #!/usr/local/bin/perl as their "shebang" line. (The reason for this complexity is that you can't change /usr/bin due to System Integrity Protection.)

Big Sur

I had a terrible mess installing and using Homebrew on Big Sur. I spent 2 days getting things to work. I hope I have recovered and won't have trouble switching to the next release.

I used PERL5LIB=/Users/myname/bin:/opt/local/lib/perl5/site_perl/5.22 and linked /usr/bin/perl to /opt/local/bin/perl to ensure that the correct version is invoked (had to temporarily disable SIP). I also set up my bash configuration to do

    export PERL5LIB=/Users/thvv/bin:/opt/local/lib/perl5/5.22
    export PERL_LOCAL_LIB_ROOT="/opt/local/lib/perl5/5.22"
    export PERL_MB_OPT="--install_base "/opt/local/lib/perl5/5.22""
    export PERL_MM_OPT="INSTALL_BASE=/opt/local/lib/perl5/5.22"

Installing Libraries and Commands

If you are installing Homebrew for the first time, you may need to remove old junk from /usr/local. If you are stopping the use of Macports, you may need to remove or rename /opt/local so you don't end up with old versions.

First thing to do is to install Perl. type sudo brew install Perl.

After you have done this, /usr/local/bin/perl should exist and be the correct version of Perl. Your shebang lines should point there.

Next do sudo brew install xxx for all the modules you want. The ones I installed are

I didn't install HTML tidy from Homebrew: it installs version 5.4.0. Use https://github.com/htacg/tidy-html5 instead, which installs version 5.9.12. (Install cmake with Homebrew, and then download the ZIP file from GitHub and build and install tidy.)

Installing MySQL

I didn't install MySQL using Homebrew. I did it using the Oracle site. Seemed to work.

Installing Perl modules from CPAN

I installed Perl modules using the cpan command provided by Homebrew.

Home | FAQ © 2010-2021, Tom Van Vleck updated 2021-09-25 11:23