My way of using Perl on MacOS
Every time I set up a new Mac, I follow a specific process to install my command-line programming tools. My goal is simple: create a development environment that closely mirrors the RHEL web servers I work with daily. This guide outlines that process.
My philosophy is to keep things as simple and transparent as possible. I often find that modern package and version managers, while powerful, add layers of complexity I don’t need. I rarely require multiple versions of a programming language on the same machine, and I don’t want to guess where my binaries and libraries are located. Instead, I prefer a stable, predictable architecture where I know exactly where to find everything.
If you share that “get off my lawn” approach to development environments, this guide is for you.
Perl
I’m now (finally!) ready to install Perl and the modules that I use every day.
In my notes from previous installations, I made a big sign for myself:
****************************************************************************
** Do *not* use the system Perl on MacOS. That is for Apple, not for you. **
****************************************************************************
Installing perl from brew is a jungle nightmare of random symbolic links and hard-coded version numbers. I don’t understand it at all. It makes it extremely difficult to upgrade the version, and I think all the compartmentalization is unnecessary for a language that prides itself on backward compatibility.
Instead, I prefer to install it to /usr/local/, without version numbers, with any modules downloaded directly in a separate location. You know, like we did it in the aughts.
$ brew install wget $ cd ~/Downloads $ wget https://www.cpan.org/src/5.0/perl-5.40.0.tar.gz $ tar xvzf perl-5.40.0.tar.gz $ cd perl-5.40.0/ $ Configure -des -Dprefix=/usr/local -Dsitelib=‘/usr/local/lib/site_perl’ -Dsitelib_stem=‘/usr/local/lib/site_perl’ -Dsitelibexp=‘/usr/local/lib/perl5/site_perl’ -Dsitearch=‘/usr/local/lib/site_perl/darwin-2level’ -Dsitearchexp=‘/usr/local/lib/site_perl/darwin-2level’ -Dinstallsitearch=‘/usr/local/lib/site_perl/darwin-2level’ -Darchlib=‘/usr/local/lib/perl5/’ -Dprivlib=‘/usr/local/lib/perl5/’ $ make $ make test $ sudo make install
Of course we’ll also need cpanm
and I use ack
instead of grep
.
$ curl -L http://cpanmin.us | perl - --sudo App::cpanminus $ cpanm --sudo App::Ack
Commonly Used Perl Modules
$ cpanm --sudo CGI $ cpanm --sudo Path::Tiny $ cpanm --sudo Data::Printer $ cpanm --sudo Mojolicious
Readline
$ brew install readline
Perl Debugger
$ cpanm --sudo DB::Pluggable $ cpanm --sudo Term::ReadLine::Gnu
Playwright.pm
Playwright.pm requires playwright
to first be installed manually.
$ sudo -E npm install -g uuid express playwright $ npx playwright install
It uses Test2::Harness which I’ve had some issues installing in the past, so let’s install it ahead of time.
$ cpanm --sudo Test2::Harness $ cpanm --sudo Sereal::Encoder $ cpanm --sudo Playwright