Zonemaster::Engine::DNSName(3p)

NAME
Zonemaster::Engine::DNSName - class representing DNS names

SYNOPSIS
    my $name1 = Zonemaster::Name->new('www.example.org');
    my $name2 = Zonemaster::Name->new('ns.example.org');
    say "Yay!" if $name1->common($name2) == 2;

ATTRIBUTES

labels
    A reference to a list of strings, being the labels the DNS name is made up from.

METHODS

new($input) _or_ new({ labels => \@labellist })
    The constructor can be called with either a single argument or with a reference to a hash as in the example above.

    If there is a single argument, it must be either a non-reference, a Zonemaster::Engine::DNSName object or a Zonemaster::Engine::Zone object.

    If it's a non-reference, it will be split at period characters (possibly after stringification) and the resulting list used as the name's labels.

    If it's a Zonemaster::Engine::DNSName object it will simply be returned.

    If it's a Zonemaster::Engine::Zone object, the value of its "name" attribute will be returned.

from_string($domain)
    A specialized constructor that must be called with a string.

string()
    Returns a string representation of the name. The string representation is created by joining the labels with dots. If there are no labels, a single dot is returned. The names created this way do not have a trailing dot.

    The stringification operator is overloaded to this function, so it should rarely be necessary to call it directly.

fqdn()
    Returns the name as a string complete with a trailing dot.

str_cmp($other)
    Overloads string comparison. Comparison is made after converting the names to upper case, and ignores any trailing dot on the other name.

next_higher()
    Returns a new Zonemaster::Engine::DNSName object, representing the name of the called one with the leftmost label removed.

common($other)
    Returns the number of labels from the rightmost going left that are the same in both names. Used by the recursor to check for redirections going up the DNS tree.

is_in_bailiwick($other)
    Returns true if $other is in-bailiwick of $self, and false otherwise. See also <https://tools.ietf.org/html/rfc7719#section-6>.

prepend($label)
    Returns a new Zonemaster::Engine::DNSName object, representing the called one with the given label prepended.

TO_JSON
    Helper method for JSON encoding.