perldoc > Domain::PublicSuffix

📖 NAME

Domain::PublicSuffix - Parse a domain down to root

🚀 Quick Reference

Use CaseCommandDescription
Parse domain to root$root = $suffix->get_root_domain('www.google.com')Returns the root domain (e.g., google.com) from a fully qualified name
Get effective TLD suffix$suf = $suffix->suffix()Returns the effective TLD (e.g., co.uk for google.co.uk)
Get true DNS TLD$tld = $suffix->tld()Returns the real DNS top-level domain (e.g., uk)
Use custom data filemy $suffix = Domain::PublicSuffix->new({ data_file => '/path/to/effective_tld_names.dat' })Override the default public suffix file
Allow underscores in hostnamesdomain_allow_underscore => 1Permit underscores (contra RFC) when parsing
Allow unlisted TLDsallow_unlisted_tld => 1Pass through domains with unlisted TLDs (follows publicsuffix.org spec)

📋 SYNOPSIS

 use Domain::PublicSuffix;

 my $suffix = Domain::PublicSuffix->new({
   'data_file' => '/tmp/effective_tld_names.dat'
 });
 my $root = $suffix->get_root_domain('www.google.com');
 # $root now contains "google.com"

 $root = $suffix->get_root_domain('www.google.co.uk');
 # $root now contains google.co.uk

 my $suf = $suffix->suffix();
 # $suf now contains co.uk

 my $tld = $suffix->tld();
 # $tld now contains uk

📝 DESCRIPTION

This module utilizes the "effective_tld_names.dat" provided by Mozilla as a way to effectively reduce a fully qualified domain name down to the absolute root. The Mozilla PublicSuffix file is an open source, fully documented format that shows absolute root TLDs, primarily for Mozilla's browser products to be able to determine how far a cookie's security boundaries go.

This module will attempt to search etc directories in /usr/share/publicsuffix, /usr, /usr/local, and /opt/local for the effective_tld_names.dat file. If a file is not found, a default file is loaded from Domain::PublicSuffix::Default, which is current at the time of the module's release. You can override the data file path by giving the new() method a 'data_file' argument.

When creating a new PublicSuffix object, the module will load the data file as specified, and use the internal structure to parse each domain sent to the get_root_domain method. To re-parse the file, you must destroy and create a new object, or execute the _parse_data_file method directly, though that is not recommended.

🔍 PUBLIC ACCESSORS

âš™ī¸ PUBLIC METHODS

🔗 SEE ALSO

🐛 BUGS

Please report any bugs or feature requests to "bug-domain-publicsuffix at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Domain-PublicSuffix. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

🆘 SUPPORT

You can find documentation for this module with the perldoc command.

 perldoc Domain::PublicSuffix

You can also look for information at:

đŸ‘Ĩ CONTRIBUTORS

ÂŠī¸ COPYRIGHT & LICENSE

Copyright 2008-2020 Nicholas Melnick, "nick at abstractwankery.com".

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Domain::PublicSuffix
📖 NAME 🚀 Quick Reference 📋 SYNOPSIS 📝 DESCRIPTION 🔍 PUBLIC ACCESSORS âš™ī¸ PUBLIC METHODS 🔗 SEE ALSO 🐛 BUGS 🆘 SUPPORT đŸ‘Ĩ CONTRIBUTORS ÂŠī¸ COPYRIGHT & LICENSE

Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-06 09:14 @216.73.217.88
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^