in reply to URL, etc to Domain Name Stripper
To do the advertised function, the sub should extract the host from an URL, determine if the host is a domain, and strip down the domain to the company level.
The first part can be done using
defined( my $host = URI->new($url)->host() ) or die("Unable to determine the host of URL $url\n");
Instead, the presented sub attempts to do the first two parts at the same time and does a bad job.
As for the third step, the sub just guesses as the OP admitted himself.
The posted sub also handles errors oddly, but that's trivial to fix.
This only works for single dot TLDs (.com, .net, .info, .ca, etc) and not intl TLDs like .co.uk etc with multiple dots.
Canada has .ca, .province.ca and .city.province.ca as suffixes, not just .ca. For example,
company.ca used to only be available to federally incorporated institutions.
|
|---|