NAME
Net::Domain::Parts - Extract sub-domain, domain and TLD parts of a domain name.
SYNOPSIS
use Net::Domain::Parts;
my $domain_name = 'www.perlmonks.org';
my ($subdomain, $domain, $tld) = domain_parts($domain_name);
printf(
"Domain %s, Subdomain %s, TLD: %s\n",
$domain,
$subdomain,
$tld
);
# Domain: perlmonks.org, Subdomain: www, TLD: org
DESCRIPTION
This module takes a fully qualified domain name, and breaks it down into its core components... the TLD, the domain name itself, and any subdomains.
FUNCTIONS
domain_parts($domain_name)
Exported by default. Breaks up an FQDN into it's core components.
Parameters:
$domain_name
Mandatory, String: A fully qualified, valid domain name string.
Returns: A list of subdomain
(undef if not present), domain
(with TLD attached) and the tld
. If the domain isn't valid (ie. doesn't exist), three undef
s will be returned.
version
Never exported. Call it as a fully qualified package function. Returns the version string of the TLD data being used.
my $version = Net::Domain::Parts::version();
print "$version\n";
# 2025-01-21_09-07-06_UTC
tld_struct
Not exported by default. Returns the internal store of TLD data.
Returns: Hash reference.
{
version => 'version_string',
third_level_domain => {
'witd.gov.pl' => 1,
'fudai.iwate.jp' => 1,
},
second_level_domain => {
'co.uk' => 1,
'prato.it' => 1,
},
top_level_domain => {
'com' => 1,
'ca' => 1,
'org' => 1,
},
}
tld_list
Not exported by default. Returns the entire list of TLDs, each TLD as a hash key.
Returns: Hash reference.
{
'org' => 1,
'com' => 1,
'co.uk' => 1,
'org.im' => 1,
'kashiwazaki.niigata.jp' => 1,
}
AUTHOR
Steve Bertrand, <steveb at cpan.org>
LICENSE AND COPYRIGHT
Copyright 2025 Steve Bertrand.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at: