{
    "mode": "perldoc",
    "parameter": "Domain::PublicSuffix",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Domain%3A%3APublicSuffix/json",
    "generated": "2026-06-12T12:57:45Z",
    "synopsis": "use Domain::PublicSuffix;\nmy $suffix = Domain::PublicSuffix->new({\n'datafile' => '/tmp/effectivetldnames.dat'\n});\nmy $root = $suffix->getrootdomain('www.google.com');\n# $root now contains \"google.com\"\n$root = $suffix->getrootdomain('www.google.co.uk');\n# $root now contains google.co.uk\nmy $suf = $suffix->suffix();\n# $suf now contains co.uk\nmy $tld = $suffix->tld();\n# $tld now contains uk",
    "sections": {
        "NAME": {
            "content": "Domain::PublicSuffix - Parse a domain down to root\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Domain::PublicSuffix;\n\nmy $suffix = Domain::PublicSuffix->new({\n'datafile' => '/tmp/effectivetldnames.dat'\n});\nmy $root = $suffix->getrootdomain('www.google.com');\n# $root now contains \"google.com\"\n\n$root = $suffix->getrootdomain('www.google.co.uk');\n# $root now contains google.co.uk\n\nmy $suf = $suffix->suffix();\n# $suf now contains co.uk\n\nmy $tld = $suffix->tld();\n# $tld now contains uk\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module utilizes the \"effectivetldnames.dat\" provided by Mozilla as a way to effectively\nreduce a fully qualified domain name down to the absolute root. The Mozilla PublicSuffix file is\nan open source, fully documented format that shows absolute root TLDs, primarily for Mozilla's\nbrowser products to be able to determine how far a cookie's security boundaries go.\n\nThis module will attempt to search etc directories in /usr/share/publicsuffix, /usr, /usr/local,\nand /opt/local for the effectivetldnames.dat file. If a file is not found, a default file is\nloaded from Domain::PublicSuffix::Default, which is current at the time of the module's release.\nYou can override the data file path by giving the new() method a 'datafile' argument.\n\nWhen creating a new PublicSuffix object, the module will load the data file as specified, and\nuse the internal structure to parse each domain sent to the getrootdomain method. To re-parse\nthe file, you must destroy and create a new object, or execute the parsedatafile method\ndirectly, though that is not recommended.\n",
            "subsections": []
        },
        "PUBLIC ACCESSORS": {
            "content": "",
            "subsections": [
                {
                    "name": "error",
                    "content": "On unsuccessful parse, contains a human-readable error string.\n"
                },
                {
                    "name": "suffix",
                    "content": "Returns the effective tld of the last parsed domain. For the domain 'google.co.uk', this\nwould return 'co.uk'.\n"
                },
                {
                    "name": "tld",
                    "content": "Returns the true DNS tld of the last parsed domain. For the domain 'google.co.uk', this\nwould return 'uk'.\n"
                }
            ]
        },
        "PUBLIC METHODS": {
            "content": "",
            "subsections": [
                {
                    "name": "new",
                    "content": "Instantiate a PublicSuffix object. It is best to instantiate an object and continue calling\ngetrootdomain instead of continually recreating the object, as the data file is read and\nparsed on instantiation.\n\nCan take a hashref of arguments:\n\ndatafile\nA fully qualified path, to override the effectivetldnames.dat file.\n\nusedefault\nUse the provided publicsuffix file, do not search for any other files.\n\ndomainallowunderscore\nA flag to indicate that underscores should be allowed in hostnames (contra to the RFCs).\nDefault: undef.\n\nallowunlistedtld\nA flag to indicate that unlisted TLDs should be passed through. This follows the spec as\nlisted on publicsuffix.org, but is not how this module works by default, or before 0.16.\nDefault: undef\n"
                },
                {
                    "name": "get_root_domain",
                    "content": "Given a fully qualified domain name, return the parsed root domain name. Returns undefined\nif an error occurs parsing the given domain, and fills the error accessor with a\nhuman-readable error string.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "*   GitHub\n\n<http://www.github.com/nmelnick/Domain-PublicSuffix>\n\n*   Current List:\n\n<http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effectivetldnames.dat?raw=1>\n[mxr.mozilla.org]\n\n*   Mozilla Documentation:\n\n<http://wiki.mozilla.org/Gecko:TLDService>\n\n*   Public Info Site:\n\n<http://publicsuffix.org/>\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Please report any bugs or feature requests to \"bug-domain-publicsuffix at rt.cpan.org\", or\nthrough the web interface at\n<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Domain-PublicSuffix>. I will be notified, and\nthen you'll automatically be notified of progress on your bug as I make changes.\n",
            "subsections": []
        },
        "SUPPORT": {
            "content": "You can find documentation for this module with the perldoc command.\n\nperldoc Domain::PublicSuffix\n\nYou can also look for information at:\n\n*   RT: CPAN's request tracker\n\n<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Domain-PublicSuffix>\n\n*   AnnoCPAN: Annotated CPAN documentation\n\n<http://annocpan.org/dist/Domain-PublicSuffix>\n\n*   CPAN Ratings\n\n<http://cpanratings.perl.org/d/Domain-PublicSuffix>\n\n*   Search CPAN\n\n<http://search.cpan.org/dist/Domain-PublicSuffix>\n",
            "subsections": []
        },
        "CONTRIBUTORS": {
            "content": "dkg: Daniel Kahn Gillmor\n\ngavinc: Gavin Carr\n\njwieland: Jason Wieland\n\nCOPYRIGHT & LICENSE\nCopyright 2008-2020 Nicholas Melnick, \"nick at abstractwankery.com\".\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        }
    },
    "summary": "Domain::PublicSuffix - Parse a domain down to root",
    "flags": [],
    "examples": [],
    "see_also": []
}