How to trim URL to root domain?

OK, here is how I translate that into specific commands.
Please review and confirm/correct.

# Is brew installed as part of the macOS?

# Create bash_profile if it does not exit
touch ~/.bash_profile

# INSTALL PERL if not already installed
# use this rather than the perl that comes with macOS
# How can we check to see if it is already installed?
brew install perl

# INSTALL cpan
brew install cpanm

# INSTALL Required Modules
cpanm Domain::PublicSuffix
cpanm Net::Domain::ExpireDate
cpanm Date::Calc

# SET KM VARIABLES
ENV_PATH: /usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin 
ENV_PERL5LIB: /usr/local/Cellar/perl/5.26.0/lib/perl5/site_perl/5.26.0

Nope. Your KM variables are missing exactly the most important parts:

ENV_PATH: /usr/local/bin (before the others, separated by a :). See here.

ENV_PERL5LIB: /Users/jimunderwood/perl5/lib/perl5 (also before the others). See here.

The rest seems correct. But do not blindly execute all in a row. Keep an eye on the messages and follow them! In case of doubt: ask.

OK, here’s my revised instructions:

# Is brew installed as part of the macOS?

# Create bash_profile if it does not exit
touch ~/.bash_profile

# INSTALL PERL if not already installed
# use this rather than the perl that comes with macOS
# How can we check to see if it is already installed?
brew install perl

# INSTALL cpan
brew install cpanm

# INSTALL Required Modules
cpanm Domain::PublicSuffix
cpanm Net::Domain::ExpireDate
cpanm Date::Calc

# SET KM VARIABLES (Rev 1)
ENV_PATH: /usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin 
ENV_PERL5LIB: /Users/<MacUserName>/perl5/lib/perl5:/usr/local/Cellar/perl/5.26.0/lib/perl5/site_perl/5.26.0

Questions:

  1. Is brew installed as part of the macOS?
  2. How can we check to see if perl is already installed?

Seems fine. Give it a try :wink:

No. See here how to install it. BTW, I do not want to force you to use Homebrew. There are other package managers, like MacPorts. So feel free to use whichever you want.

perl is installed on every macOS, as well as ruby and python etc. But if you are using a scripting language regularly I wouldn't meddle too much with the ones installed by default, because these are going to be used by other programs and maybe even the system itself. In addition the preinstalled versions are rarely up-to-date.

With

type -a perl

you can see all installed perl versions.

I have no preference, or knowledge about package managers.
If you like Homebrew then that's good enough for me. :wink:

Thanks again for your help.

If you are going to use HB it has the advantage that I'm able to help you. MacPorts may install perl differently, I don't know.

1 Like

There is a slight error in your to-do list:

# INSTALL cpan
brew install cpanm

cpancpanm

  • cpan is the “normal” CPAN package (module) manager. It can be a bit difficult to handle.
  • cpanm (aka cpanminus) is an alternate (but well established) package manager. It is less difficult to handle, IMO.
  • CPAN (uppercase) is the module archive itself.

this creates an EMPTY file???

What should be in it?

Leave it empty.
When installing perl via HB (and following the instruction messages in the Terminal) you should find this in .bash_profile:

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

See here for an explanation of local::lib.

Without that the modules will end up in /usr/local/Cellar/perl/5.26.0…, which has the disadvantage that you have to reinstall every module after each perl update.

After I installed perl, I got this:

By default non-brewed cpan modules are installed to the Cellar. If you wish
for your modules to persist across updates we recommend using `local::lib`.

You can set that up like this:
  PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib
  echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >> ~/.bash_profile

Should I do that?

Yep, the message is describing exactly what I have said in the last post. So, please, do it! :slight_smile:

Check your .bash_profile afterwards for that line. (Before installing cpanm.) and check also the env variables by executing this

env | grep 'perl'

Post the output here.

OK, .bash_profile:

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

That produced NO output?

Try env | grep -i 'perl'

just env produces this:

TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/_2/7b0tgl916vg3ft82hgl011vm0000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.bRdloxCW1p/Render
TERM_PROGRAM_VERSION=361.1
TERM_SESSION_ID=83137546-A959-4881-81CE-CDBAFE939369
USER=jimunderwood
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.Jr3itOHstg/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
PWD=/Users/jimunderwood
LANG=en_US.UTF-8
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/jimunderwood
LOGNAME=jimunderwood
_=/usr/bin/env

Also NO output.

Looks like perl was installed OK:

MBP-15R-1-JMU:~ jimunderwood$ type -a perl
perl is /usr/local/bin/perl
perl is /usr/bin/perl

Open a new Terminal window and try again, please. (env | grep -i ‘perl’)

OK, that worked:

MBP-15R-1-JMU:~ jimunderwood$ env | grep -i 'perl'
PERL5LIB=/Users/jimunderwood/perl5/lib/perl5
PERL_MB_OPT=--install_base "/Users/jimunderwood/perl5"
PATH=/Users/jimunderwood/perl5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
PERL_LOCAL_LIB_ROOT=/Users/jimunderwood/perl5
PERL_MM_OPT=INSTALL_BASE=/Users/jimunderwood/perl5
MBP-15R-1-JMU:~ jimunderwood$