How to trim URL to root domain?

When installing perl via Homebrew, have you seen and followed the instruction that have said something like this?:

PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib
echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >> ~/.bash_profile

Or: do you have the line

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

in your .bash_profile ?

Don't remember that.
I don't seem to have a bash profile:

iMac-27-JMU:~ jimunderwood$ open -a BBEdit.app .bash_profile
The file /Users/jimunderwood/.bash_profile does not exist.

How do I create it, and what should be in it?

Then in the ~./bashrc ?

I found this helpful article. Should I follow it to create bash profile?
MY MAC OSX BASH PROFILE

iMac-27-JMU:~ jimunderwood$ open -a BBEdit.app ~./bashrc
The file /Users/jimunderwood/~./bashrc does not exist.

The Domain::PublicSuffix module you have installed before, is it located here? That is, do you have this folder?

~/perl5/lib/perl5/Domain/PublicSuffix

!? If you don't have a .bash_profile and don't have a .bashrc, where is your bash config stored? I mean your bash aliases and all that stuff?

I'm just seeing you have searched at the wrong path. It is ~/.bashrc, not /Users/jimunderwood/~./bashrc

How would I search differently from this:

iMac-27-JMU:~ jimunderwood$ open -a BBEdit.app .bash_profile
The file /Users/jimunderwood/.bash_profile does not exist.
iMac-27-JMU:~ jimunderwood$ open -a BBEdit.app ~./bashrc
The file /Users/jimunderwood/~./bashrc does not exist.
iMac-27-JMU:~ jimunderwood$ open -a BBEdit.app ~/.bashrc
The file /Users/jimunderwood/.bashrc does not exist.
iMac-27-JMU:~ jimunderwood$ cd ~/
iMac-27-JMU:~ jimunderwood$ open -a BBEdit.app .bashrc
The file /Users/jimunderwood/.bashrc does not exist.
iMac-27-JMU:~ jimunderwood$ 

Isn't ~/ the same as my home dir, which is jimunderwood$ ?

Yes. But above you have written The file /Users/jimunderwood/~./bashrc does not exist. I was referring to that.

Have you found the module in this location?

Well, if the modules aren’t there, they should be in /usr/local/Cellar/perl/5.26.0/lib/perl5/site_perl/5.26.0.

So I propose:

In KM make a variable named ENV_PERL5LIB and paste this into it:

/Users/jimunderwood/perl5/lib/perl5:/usr/local/Cellar/perl/5.26.0/lib/perl5/site_perl/5.26.0

Check if you have the same perl version as in the path (5.26.0).

If perl (run from within KM) finds its modules now, but you get a weird dyld: error, then in the script replace the

#!/usr/bin/env perl

with

#!/usr/local/bin/perl

OK, I DO have that folder, but I can't find "PublicSuffix" folder anywhere on my mac.

But you did install the Domain::PublicSuffix module? (cpanm Domain::PublicSuffix)

If not then type

cpanm Domain::PublicSuffix

in the Terminal. (Assuming you have installed cpanm.)

If the module is already installed you’ll get a message saying that is up to date.

To make it clear:

cpanm and cpan are “package managers” for CPAN (the perl module archive).

Domain::PublicSuffix is a module (there are thousands of different modules)

cpanm is easier to use than cpan, so the point of installing cpanm was to make it easier for you to install modules, in our case the Domain::PublicSuffix module.

KM (and the Terminal) need to know the location of the modules. But this depends on how you have installed perl, more precisely, if you have installed it with the locallib option or not (this was the instruction that popped up during the install with Homebrew).

So, the situation is, that I don’t know where your modules are located. But with both alternative paths in the ENV_PERL5LIB variable it should work.

No. You didn't tell me to. :wink:
You just said:

But no problem. I'll try that now. . .

OK, it seems to have installed OK:

iMac-27-JMU:~ jimunderwood$ cpanm Domain::PublicSuffix
--> Working on Domain::PublicSuffix
Fetching http://www.cpan.org/authors/id/N/NM/NMELNICK/Domain-PublicSuffix-0.14.1.tar.gz ... OK
Configuring Domain-PublicSuffix-0.14 ... OK
==> Found dependencies: Class::Accessor::Fast, Net::IDN::Encode
--> Working on Class::Accessor::Fast
Fetching http://www.cpan.org/authors/id/K/KA/KASEI/Class-Accessor-0.34.tar.gz ... OK
Configuring Class-Accessor-0.34 ... OK
Building and testing Class-Accessor-0.34 ... OK
Successfully installed Class-Accessor-0.34
--> Working on Net::IDN::Encode
Fetching http://www.cpan.org/authors/id/C/CF/CFAERBER/Net-IDN-Encode-2.400.tar.gz ... OK
==> Found dependencies: Module::Build
--> Working on Module::Build
Fetching http://www.cpan.org/authors/id/L/LE/LEONT/Module-Build-0.4224.tar.gz ... OK
Configuring Module-Build-0.4224 ... OK
Building and testing Module-Build-0.4224 ... OK
Successfully installed Module-Build-0.4224
Configuring Net-IDN-Encode-2.400 ... OK
==> Found dependencies: Test::NoWarnings
--> Working on Test::NoWarnings
Fetching http://www.cpan.org/authors/id/A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz ... OK
Configuring Test-NoWarnings-1.04 ... OK
Building and testing Test-NoWarnings-1.04 ... OK
Successfully installed Test-NoWarnings-1.04
Building and testing Net-IDN-Encode-2.400 ... OK
Successfully installed Net-IDN-Encode-2.400
Building and testing Domain-PublicSuffix-0.14 ... OK
Successfully installed Domain-PublicSuffix-0.14
5 distributions installed
iMac-27-JMU:~ jimunderwood$ 

Now I'll try my KM macro.

Failed again with same error.

Can't locate Domain/PublicSuffix.pm in @INC (you may need to install the Domain::PublicSuffix module) (@INC contains: /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.2 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at /var/folders/hb/6xgg0y8j4g530m81rd1f9mpc0000gn/T/Keyboard-Maestro-Script-3801BC5F-2E88-424A-B738-F5981E9E5658 line 7.
BEGIN failed--compilation aborted at /var/folders/hb/6xgg0y8j4g530m81rd1f9mpc0000gn/T/Keyboard-Maestro-Script-3801BC5F-2E88-424A-B738-F5981E9E5658 line 7.

But the BBEdit version worked:

================================================================================
Sep 8, 2017, 8:10:29 PM
/Users/Shared/Dropbox/SW/DEV/Projects/[KM] Extract Domain Name/Get-Domain.pl
--------------------------------------------------------------------------------
db.de

Hmmm, Terminal reports a different Perl ver than the above km error.
From Terminal:

iMac-27-JMU:~ jimunderwood$ perl -v

This is perl 5, version 26, subversion 0 (v5.26.0) built for darwin-thread-multi-2level

My KM Macro is one simple Action:

I think I see the problem. In your script you have:
use 5.010;

yet I have Ver 5.26.

Should I change the use 5.010;, or just remove it?

Well, when I use use 5.26.0;, I get:

Perl v5.26.0 required--this is only v5.18.2, stopped at /var/folders/hb/6xgg0y8j4g530m81rd1f9mpc0000gn/T/Keyboard-Maestro-Script-B863094A-49FB-49F9-9DBE-217ED2E186B9 line 3.
BEGIN failed--compilation aborted at /var/folders/hb/6xgg0y8j4g530m81rd1f9mpc0000gn/T/Keyboard-Maestro-Script-B863094A-49FB-49F9-9DBE-217ED2E186B9 line 3.

I must have the wrong path or something in the KM Shell Script.

Leave it.

Please read my last post. I think we have posted at the same time.

If KM reports a perl version 5.18 then your ENV_PATH variable (in KM) does not include the Homebrew install path.

In that case change the shebang line as said here.

The use 5.010 only tells the minimum required version. And both, 5.26 and 5.18, are higher, so it doesn’t matter. But make sure KM is using the 5.26 version (the one installed via Homebrew.) Otherwise you are likely to get additional problems with the modules path.