# phpman > info > IO::Socket::SSL::PublicSuffix

[IO::Socket::SSL::PubliUserfContributed](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3ASSL%3A%3APubliUserfContributed/markdown) Perl [IO::Socket::SSL](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3ASSL/markdown)::[PublicSuffix(3pm)](https://www.chedong.com/phpMan.php/man/PublicSuffix/3pm/markdown)

NAME
       [IO::Socket::SSL::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3ASSL%3A%3APublicSuffix/markdown) - provide access to Mozilla's list of
       effective TLD names

SYNOPSIS
           # use builtin default
           use [IO::Socket::SSL::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3ASSL%3A%3APublicSuffix/markdown);
           $ps = [IO::Socket::SSL::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3ASSL%3A%3APublicSuffix/markdown)->default;

           # load from string
           $ps = [IO::Socket::SSL::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3ASSL%3A%3APublicSuffix/markdown)->from_string("*.uk\n*");

           # load from file or file handle
           $ps = [IO::Socket::SSL::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3ASSL%3A%3APublicSuffix/markdown)->from_file($filename);
           $ps = [IO::Socket::SSL::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3ASSL%3A%3APublicSuffix/markdown)->from_file(\*STDIN);

           # --- string in -> string out
           # $rest -> whatever.host
           # $tld  -> co.uk
           my ($rest,$tld) = $ps->public_suffix('whatever.host.co.uk');
           my $tld = $ps->public_suffix('whatever.host.co.uk');

           # $root_domain -> host.co.uk
           my $root_domain = $ps->public_suffix('whatever.host.co.uk', 1);

           # --- array in -> array out
           # $rest -> [qw(whatever host)]
           # $tld  -> [qw(co uk)]
           my ($rest,$tld) = $ps->public_suffix([qw(whatever host co uk)]);

        ----

           # To update this file with the current list:
           perl -[MIO::Socket::SSL::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/MIO%3A%3ASocket%3A%3ASSL%3A%3APublicSuffix/markdown) -e '[IO::Socket::SSL::PublicSuffix::update_self_from_url](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3ASSL%3A%3APublicSuffix%3A%3Aupdateselffromurl/markdown)()'

DESCRIPTION
       This module uses the list of effective top level domain names from the
       mozilla project to determine the public top level domain for a given
       hostname.

   Method
       class->default(%args)
           Returns object with builtin default.  "min_suffix" can be given in
           %args to specify the minimal suffix, default is 1.

       class->from_string(string,%args)
           Returns object with configuration from string.  See method
           "default" for %args.

       class->from_file( file name| file handle, %args )
           Returns object with configuration from file or file handle.  See
           method "default" for %args.

       $self->public_suffix( $host|\@host, [ $add ] )
           In array context the function returns the non-tld part and the tld
           part of the given hostname, in scalar context only the tld part.
           It adds $add parts of the non-tld part to the tld, e.g. with
           "$add=1" it will return the root domain.

           If there were no explicit matches against the public suffix
           configuration it will fall back to a suffix of length 1.

           The function accepts a string or an array-ref (e.g. host split by
           "."). In the first case it will return string(s), in the latter
           case array-ref(s).

           International hostnames or labels can be in ASCII (IDNA form
           starting with "xn--") or unicode. In the latter case an IDNA
           handling library needs to be available.  URI is preferred, but
           [Net::IDN](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AIDN/markdown):::Encode, [Net::LibIDN](https://www.chedong.com/phpMan.php/perldoc/Net%3A%3ALibIDN/markdown) are still supported.

       ($self|class)->can_idn
           Returns true if IDN support is available.

FILES
       <http://publicsuffix.org/list/effective_tld_names.dat>

SEE ALSO
       [Domain::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/Domain%3A%3APublicSuffix/markdown), [Mozilla::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/Mozilla%3A%3APublicSuffix/markdown)

BUGS
        Q: Why yet another module, we already have L<[Domain::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/Domain%3A%3APublicSuffix/markdown)> and
           L<[Mozilla::PublicSuffix](https://www.chedong.com/phpMan.php/perldoc/Mozilla%3A%3APublicSuffix/markdown)>.
        A: Because the public suffix data change more often than these modules do,
           [IO::Socket::SSL](https://www.chedong.com/phpMan.php/perldoc/IO%3A%3ASocket%3A%3ASSL/markdown) needs this list and it is more easy this way to keep it
           up-to-date.

AUTHOR
       Steffen Ullrich

perl v5.32.1                      2022-01-[13IO::Socket::SSL](https://www.chedong.com/phpMan.php/perldoc/13IO%3A%3ASocket%3A%3ASSL/markdown)::[PublicSuffix(3pm)](https://www.chedong.com/phpMan.php/man/PublicSuffix/3pm/markdown)
