No, I didn't intend this solution for the OP of this thread.
Yes, there is. Basically you can distribute any module with your script. (You just have to add 2 lines in the script with the location of the module.) I've done this with LB actions that include a perl script and need modules. With LB this is easy, since you can just include all resources inside the action bundle.
With KM it's not so easy because a macro file cannot include resources und you would have to tell the user where to put exactly the other files. See this thread
I actually made use of document.domain JS, and [^.]+.[^.]+$ to trim server names to domain name. The JS part actually saved me my additional step of copying URL to clipboard.
I actually designed a macro that shows age in format like 2 years, 3 months, and 4 days old. It's inflating the actual age by 4-5 days for old domains. I think this is due to Keyboard Maestro rounds off values especially in the line that says zzzAgeDaysTemp MOD 30.5
since I already started with the Perl script yesterday, I couldn't resist to complete it
Advantages over the other solution:
No wonky regex used. The domain root is determined with the help of the Current Effective TLD List. So, the script has no problems with fancy stuff like www.cs.tut.fi or kartolo.sby.datautama.net.id.
The script is auto-choosing the correct Whois server for the domain.
Since different Whois servers are using different output formats, server-specific parsers are used to extract the Domain Creation Date.
Not really important, but the age is calculated properly, not based on an average month length.
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Domain::PublicSuffix;
use Net::Domain::ExpireDate;
use Date::Calc qw(Today Delta_Days N_Delta_YMD);
# Getting the input from KM
my $url_input = qx/osascript -e 'tell application "Keyboard Maestro Engine" to getvariable "ddaURL"'/;
chomp($url_input);
# Getting domain (root)
my $suffix = Domain::PublicSuffix->new();
my $domain = $suffix->get_root_domain($url_input);
# Get creation and expiry date of domain
(my $creation_str, my $expiry_str) = domain_dates($domain, '%Y-%m-%d');
# Date calculations
my $gmt = 1;
(my $year_creation, my $month_creation, my $day_creation) = split('-', $creation_str);
(my $year_now, my $month_now, my $day_now) = Today([$gmt]);
my $delta_days_total = Delta_Days($year_creation, $month_creation, $day_creation, $year_now, $month_now, $day_now);
(my $delta_years, my $delta_months, my $delta_days) = N_Delta_YMD($year_creation, $month_creation, $day_creation, $year_now, $month_now, $day_now);
# Output
my $year_label = $delta_years == 1 ? ' year, ' : ' years, ';
my $month_label = $delta_months == 1 ? ' month, ' : ' months, ';
my $day_label = $delta_days == 1 ? ' day' : ' days';
say 'Domain: ' . $domain;
say 'Creation date: ' . $creation_str;
say 'Expiry date: ' . $expiry_str;
say 'Age: ' . $delta_years . $year_label . $delta_months . $month_label . $delta_days . $day_label;
say 'Age in days: ' . $delta_days_total;
__END__
=begin comment
For best results:
Download the most recent TLD names list from
http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1
and save it @ /usr/local/effective_tld_names.dat
=end comment
Update (2017-09-11):
Output: Correct singular forms now ("1 month", not "1 months", etc.)
Oh heck, the odyssey is such fun, let's continue it!
I get this 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/_2/7b0tgl916vg3ft82hgl011vm0000gn/T/Keyboard-Maestro-Script-66D1CE2A-91C9-43AA-AD6C-3FB89C73DDBF line 7.
BEGIN failed--compilation aborted at /var/folders/_2/7b0tgl916vg3ft82hgl011vm0000gn/T/Keyboard-Maestro-Script-66D1CE2A-91C9-43AA-AD6C-3FB89C73DDBF line 7.
Maybe, someday. But, as you have seen, there is more than one way to install perl
This information can be found in the Perl script, and perl itself is already testing for the presence of the required modules. (See the error message you have posted above.)
IIRC you succeeded to install perl 5.26 and cpanm on your other Mac two days ago. So I suggest to first read through the posts from two days ago.
To sum it up:
Install perl via Homebrew. Follow the instructions you see in the Terminal during/after the install. (Speaking namely of this one.)
Install cpanm as you have done two days ago.
Create the ENV_PERL5LIB variable in KM with the paths as shown. It is also extremely helpful that you set up your ENV_PATH variable so that it includes the Homebrew install path. These are for example my paths: