ParseUtil::Domain - Domain parser and puny encoder/decoder.
use ParseUtil::Domain ':parse'; my $processed = parse_domain("somedomain.com"); #$processed: #{ #domain => 'somedomain', #domain_ace => 'somedomain', #zone => 'com', #zone_ace => 'com' #}
This purpose of this module is to parse a domain name into its respective name and tld. Note that the tld may actually refer to a second- or third-level domain, e.g. co.uk or plc.co.im. It also provides respective puny encoded and decoded versions of the parsed domain.
This module uses TLD data from the Public Suffix List which is included with this distribution.
1. parse_domain('somedomain.com'); Result: { domain => 'somedomain', zone => 'com', domain_ace => 'somedomain', zone_ace => 'com' } 2. parse_domain('test.xn--o3cw4h'); Result: { domain => 'test', zone => 'ไทย', domain_ace => 'test', zone_ace => 'xn--o3cw4h' } 3. parse_domain('bloß.co.at'); Result: { domain => 'bloss', zone => 'co.at', domain_ace => 'bloss', zone_ace => 'co.at' } 4. parse_domain('bloß.de'); Result: { domain => 'bloß', zone => 'de', domain_ace => 'xn--blo-7ka', zone_ace => 'de' }
Toggles a domain between puny encoded and decoded versions.
use ParseUtil::Domain ':simple'; my $result = puny_convert('bloß.de'); # $result: xn--blo-7ka.de my $reverse = puny_convert('xn--blo-7ka.de'); # $reverse: bloß.de
Updated with latest version of the public suffix list.
Added a bunch of new TLDs (nTLDs).
Now uses perl5i.
To install ParseUtil::Domain, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ParseUtil::Domain
CPAN shell
perl -MCPAN -e shell install ParseUtil::Domain
For more information on module installation, please visit the detailed CPAN module installation guide.